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;
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 3 months ago.
Improve this question
I have two tables: userdata and videodata. I have the email as the primary key in the first table (userdata) and I want to use email in the second table (videodata) as a foreign key.
userdata table-
Whenever I execute the query for the videodata table creation, I get this error-
Here is the query for creating videodata table-
LIKE is a reserved word. Enclose it in back ticks.
create videDate (
...
`like` int,
...
);
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
I have fields (pay_area, varchar(20)) with different values in my MySQL database. Some of them are like blabla.one blabla.two etc and others are completely different.
For example:
blabla.one, ads, blabla.one, payment, blabla.tree and so on.
I have to count all the fields starting only with blabla.
How can I do that?
SELECT count(id)
FROM TABLE
WHERE pay_area LIKE 'blabla.%'
If you want to fetch more fields then you can select other columns as well
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 4 years ago.
Improve this question
How to copy a cell value from another row in the same table?
UPDATE mytable SET myvalue=(SELECT myvalue FROM mytable WHERE id=2) WHERE id=11
It gives an error message:
Table 'mytable' is specified twice, both as a target for 'UPDATE' and as a separate source for data
Thank you
UPDATE mytable SET id=11, mycol=a.mycol FROM (SELECT mycol FROM mytable WHERE id=2) a
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
Can anyone tell me what have I got wrong here?
UPDATE `oc_product`
SELECT `model` = TRIM(BOTH ''' FROM '`model`')
The database is ocart2, the table is oc_product and the column is model.
I am trying to remove the ' from a model number.
eg: it currently is '123456' I want it to be 123456
This is the proper syntax
UPDATE `oc_product` SET `model` = TRIM(BOTH '\'' FROM model);
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.