How to concat column using myng'sql? [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 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.

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

Query Execution [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
How to execute this query in laravel. ?
select d1.update_id from ( select update_id, count(update_id)
as ct from updates_tags where tag_id in (67,33,86,55) group by
update_id) as d1 where d1.ct=4
you can use Raw Queries in Laravel
$results = DB::select(SELECT * FROM table WHERE id IN (1,2,3,4) AND );
http://fideloper.com/laravel-raw-queries
You can chain where conditions with eloquent, each chained one is evaluated like an and.
$update = Tag::whereIn('t_id',$tags)->whereIn('u_id',$tags)->where(/*more and conditions you could need*/)->lists('u_id')
Edit: If you need the ones coincident with u_id consider this:
$update = DB::table('tags')
->select('t_id', 'u_id', DB::raw('count(*) as total'))
->whereIn('t_id',$tags)
->where('total','=',count($tags))
->groupBy('u_id')
->lists('u_id');

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

query="SELECT * FROM Table WHERE `VarCharCol1`= numeric" [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 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).

Categories