Really simple Django query [closed] - mysql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to save in aux this query
select id from principal_dep where dep_name='Field';
the user selects the field in a form. I have this which is obviously wrong
aux = Dep.objects.filter(id=request.POST['dept'])
how can I do this?, help!

dep = Dep.objects.get(dep_name=request.POST['dept'])
dep_id = dep.id
or
dep_ids = Dep.objects.filter(dep_name=request.POST['dept']).values_list('id', flat=True)

Related

Invalid object name 'table1.CreatedAt'. Error coming in SQL server even though the table exists [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
Improve this question
SELECT table1.CreatedAt
FROM table1
LEFT JOIN table1.CreatedAt
ON table1.CreatedAt=[testDebtMarketData$].Date
WHERE [testDebtMarketData$].Date = NULL
but when I do SELECT * FROM table1 it works and I can see the table...
You need to specify a table directly after LEFT JOIN, not a column.

cant delete all records in IN clause mysql [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am running this query,
DELETE FROM media WHERE id IN ('19,18')
Its only deleting record with id 19 as you can see in the picture.
The column type of id is integer though.
You are passing a string which is being converted to the first integer (19). Remove the quotes.
DELETE FROM media WHERE id IN (19,18)

select date column on mysql is giving only 0000-00-00 results [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm using this query
select date_of_birth from clients
where date_of_birth BETWEEN '1988-11-09' and '1968-11-09';
but only gives 0000-00-00 results,what is wrong?
Smaller value should be on the left side and bigger on the right side in case of BETWEEN .. AND ..:
select date_of_birth from clients
where date_of_birth BETWEEN '1968-11-09' and '1988-11-09';

Aggregation function error in mysql query [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
select avg(eff),min(eff),max(eff)
from(select Job_Render/(LC_Final+LC_Preview))as eff from ras)as s;
I am going somewhere wrong where i am not able to figure it out.
You had a ) too much in your subquery
select avg(eff),min(eff),max(eff)
from
(
select Job_Render/(LC_Final+LC_Preview) as eff
from ras
)as s;

Data Base Query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a database like this:-
state_name|district_name|id
jammu |kupwara |jk-01
kashmir |anantnag |jk-02
I want a mysql Query such that when
statename is selected (jammu), distname should be selected(kupwara) based on thier id.
If any one knows please help me out.Thanks in Advance
If I understood your question properly, then query should be like this
SELECT state_name,district_name from TableName WHERE id='jk-01' //you can have your specific id here