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 7 years ago.
Improve this question
What is wrong with this syntax:
DELETE FROM customer WHERE id IN ('1,3')
Customer table:
It deletes only the row with id = 1. I'm expecting empty table. If I leave there only one row with id=3, it says that deleted records: 0.
No need for ' around values:
DELETE FROM customer WHERE id IN (1,3);
You are looking for a single value that is a string with three characters: '1,3', not two numeric values.
If you are constructing the query, then you should try to construct it with a proper in list. Under some circumstances, you might find it more convenient to use find_in_set():
DELETE FROM customer WHERE find_in_set(id, '1,3') > 0
However, this cannot use an index, so lad2025 is a better general solution.
You don't need to use single quotes around Number fields. You are supposed to use single quotes around character values.
Related
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 2 years ago.
Improve this question
So basically I want to select all of the columns in that table, while also concatting a specific column.
E.g. (This code doesnt work obviously)
select *
concat("$", Cost),
from Restaurant
Order by Cost desc;
So basically it will print all the values and add a $ infront of the (decimal) values of the Cost table.
I know how to just do that column itself and make it work, which would be
SELECT CONCAT("$", Cost) AS Cost
FROM Restaurant;
Which works but only prints out that column. How would I get it to print all the columns while still adding the $ sign to the cost column?
seems like just misplacing comma in your select :
select
* ,
concat("$", Cost)
from Restaurant
Order by Cost desc;
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 3 years ago.
Improve this question
SQL beginner here. I have this database: https://github.com/socratica/data/blob/master/earthquake.csv
I'm running a simple Query such as:
SELECT place, DEPTH1 , OCCURED_ON from EARTHQUAKE1;
I execute it, and get the info I need. However, when I add WHERE depth1 = 35; (I edited the depth col just in case it was conflicting with some other clause)
the GUI returns an error. I tried adding ' and using like, also using TRIM but no luck. I also tried retrieving data from another col, but still no good. What is it that I'm doing brutally wrong?
Thanks in advance!
You have a semicolon after your FROM and before your WHERE.
SQL is reading the WHERE as a separate statement and failing.
The ; is a statement terminator.
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 3 years ago.
Improve this question
I started using MySQL recently and I am facing a problem. I created two tables using create table command and inserted value in the table. These two commands were executed successfully. Then I tried using select command. When I try to execute this command it shows
"select" is not valid at this position for this server version, expecting: (, WITH
Here is my command:
select
*
from Employee,
where Gender="M" and NativePlace="Mumbai",
order Hobby by desc;
What is the reason for this?
There are a couple of syntax errors in your query, try this:
select
*
from Employee
where Gender='M' and NativePlace='Mumbai'
order by Hobby desc;
Remove the commas after Employee and "Mumbai" and you should be good.
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 years ago.
Improve this question
Im trying to pull out only "completed" orders
whats the problem in this select code?
('SELECT * FROM orders WHERE OrderUserID = :OrderUserID AND WHERE OrderStatus='Completed');
You have a single quote before the SELECT and then two more around the 'Completed'.
Replace the single quote at the start with a double, and put one at the end as well.
You also have an additional WHERE before your second condition. Normally you just say 'WHERE this AND this AND this'.
("SELECT * FROM orders WHERE OrderUserID = :OrderUserID AND OrderStatus='Completed'");
The query only needs one "WHERE" clause, unless using subqueries.
(SELECT * FROM orders WHERE OrderUserID = :OrderUserID AND OrderStatus='Completed');
Try this. You AND the conditions when you want to have multiple constraints on the retreiving data.
("SELECT * FROM orders WHERE OrderUserID = :OrderUserID AND OrderStatus='Completed'");
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 9 years ago.
Improve this question
INSERT INTO person_data('Key','value',Person_id)
SELECT 'aaa','bbb',1, FROM person_data;
could someone please indicate what is the issue with the above statement?
is that because 'key' and 'value' are sensitive words? Any help?
Key is a column name which also happen to be keyword and should not be put inside qoutes but backticks. Also remove last comma in Select list.
INSERT INTO person_data
( ` KEY ` ,
value,
person_id)
SELECT 'aaa',
'bbb',
1
FROM person_data;
INSERT INTO person_data(`Key`,`value`,`Person_id`) VALUES ('$key', '$value', '$Person_id')
SELECT * FROM person_data;
There is no need to quote the column names.
Try this:
INSERT INTO person_data(Key,value,Person_id) SELECT 'aaa','bbb',1, FROM person_data;