Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql select multiple rows into one column

SELECT
	GROUP_CONCAT(DISTINCT id SEPARATOR ', ') AS 'ids'
FROM
	table_name
WHERE
	column_name = 'value'
Comment

mysql count multiple columns in one query

mysql count multiple columns in one query:
 SELECT 
        count(*)             as count_rows,
        count(col1)          as count_1,
        count(col2)          as count_2,
        count(distinct col1) as count_distinct_1,
        count(distinct col2) as count_distinct_2,
        count(distinct col1, col2) as count_distinct_1_2
    FROM `table` ;
Comment

how to select multiple columns from different tables in mysql

-- MySQL 
-- t1 = table1
-- dt2 = column of table
SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
FROM table1 t1, table2 t2 -- Doesn't need to have t1, or t2
WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456
Comment

PREVIOUS NEXT
Code Example
Sql :: sql distinct with count 
Sql :: sql in array query 
Sql :: oracle sql create table from select 
Sql :: ignore case like sql 
Sql :: date_part mysql 
Sql :: mysql database create 
Sql :: command line mysql xampp 
Sql :: postgres float to int 
Sql :: mysql show table fields 
Sql :: check constraint in sql 
Sql :: how to use rank function in sql 
Sql :: sql mm/dd/yyyy format 
Sql :: select nextval from sequence sql 
Sql :: how to drop a table in mysql 
Sql :: sql function 
Sql :: sql stored procedure with output parameters 
Sql :: string to sql timestamp 
Sql :: create a sqlite database c# 
Sql :: postgresql get today 
Sql :: check if sql is installed 
Sql :: date sql get the last week count 
Sql :: difference between super key and candidate key 
Sql :: alter table name sql 
Sql :: sqlalchemy return id after insert 
Sql :: use group_concat in concat 
Sql :: How to add a Try/Catch to SQL Stored Procedure 
Sql :: constraints to columns SQL 
Sql :: update with inner join sql server 
Sql :: import sql dump into postgresql database 
Sql :: sql injection payload list github 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =