query="SELECT * FROM Table WHERE `VarCharCol1`= numeric" [closed] - php

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).

Related

php code to delete value table 2 from value of table 1 [closed]

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;

How to query database column names? [closed]

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_%'

How to concat column using myng'sql? [closed]

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 6 years ago.
Improve this question
I am using following,
select * , CONCAT_WS( row1.',' , combined_data) AS combined_data from table
Actually i looking the data like
row1 Value , row2 Value , row3 Value, ..
Please help me to resolve my problem
You can try like this..
select * , CONCAT_WS( ',',column_name1,colimn_name2) AS combined_data from table
The syntax for CONCAT_WS is
CONCAT_WS (separator, string1, string2,…)
Which is is used to join two or more strings with a separator.

Select and sort data from one table on certain columns [closed]

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

How to search a CSV column for a value in MySQL? [closed]

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

Categories