Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to update all the selected items in sql.
For example, in a table I have a lot of item, all of them with a name. I want to update all this items where the name is 'aaa' for example.
Anybody knows how to do that easy?
Thanks
Best regards
It really depend upon how you want to handle update.
e.g,
1. Update all records where FIELD_NAME equal to aaa
UPDATE TABLE_NAME WHERE FIELD_NAME = 'aaa';
2. Update all records where FIELD_NAME is matched with aaa
UPDATE TABLE_NAME WHERE FIELD_NAME LIKE '%aaa%';
3. Update all records where FIELD_NAME is matched and start with aaa
UPDATE TABLE_NAME WHERE FIELD_NAME LIKE 'aaa%';
4. Update all records where FIELD_NAME is matched and end with aaa
UPDATE TABLE_NAME WHERE FIELD_NAME LIKE '%aaa';
You have to use UPDATE clause to update records with Where clause to update only selected records
https://msdn.microsoft.com/en-us/library/ms177523.aspx
UPDATE tblName
SET columnname = newValue
WHERE name = 'aaa'
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am php beginner.
I would like to read email contain in table 1 and with the value selected deleted the corresponding email of the table 2 ?
May you provide me some info to manage it ?
select email_table1 from table1.
delete from table2 where email = email_table1.
Thanks
Greg
There's little information to form an answer but you could use a sub select.
Something like this presuming you're using MySQL or similar.
DELETE FROM `table1` WHERE id = (
SELECT `referenceID` FROM `table2` WHERE `email` = 'the#email.com' LIMIT 1
) LIMIT 1;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a table with multiple columns starting with one keyword link_. I.E. link_0_10, link_10_20, link_20_30 and so on.
I want to select only columns starting with these link_ keywords. How to do that? I can query by RegEx on the value, but on the columns? I have not been able to.
P.S.: I have no prior idea of how many columns may be present.
just change database name and table name with yours and run this query
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='database_name'
AND `TABLE_NAME`='table_name' and COLUMN_NAME like 'link_%'
SELECT *
FROM information_schema.columns
WHERE table_name = 'mytable' and column_name like 'link_%'
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm looking to see if it is possible to select data from table A with a sort so the order of the data changes.
I then want to make a loop so it will go through each row and add it into table B.
Is this possible.
Use a variable #row_number to store the incremented num for your expected sorting.
SET #row_number = 0;
SELECT (#row_number:=#row_number + 1) AS num, Column1
FROM TableA
ORDER BY Column1
This result can be store in temporary table and based on that you can do loop/insert into the TableB
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to select those ids where staff id contain 3. Below is my database structure:
ID NAME Staff_ids
-----------------------
1 A 0,212,5
2 B 2,3,600
3 C 0,1,4
I want a query where I can select those ids having 3 in staff_ids column. How can I do that please help
You can use FIND_IN_SET.
Here is SQLFiddle Demo
Input :
Output:
SELECT * FROM table_name WHERE FIND_IN_SET('3',Staff_ids)>0
Hope this helps.
SELECT *
FROM ABC
WHERE Staff_id IN ('3');
Check if this helps
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a table with varchar column, this column contains both numeric records and AlphaNumeric records, but require only the ones that have no letters.
How can I achieve this?
Try this:
SELECT * FROM table WHERE `varcharcol1` RLIKE '^[0-9]+$'
tryed
SELECT column_name FROM table WHERE ISNUMERIC(column_name) = 1
select * from table where concat('', column * 1) = column;
Returns array of data, where column is numeric (contains only digits).