select * from query in sql code example
Example 1: sql select from select
SELECT t1.*
FROM t1
WHERE t1.MY_FIELD = (SELECT t2.MY_FIELD
FROM t2
WHERE t2.MY_FIELD = t1.MY_FIELD);
Example 2: how select from db
SELECT columname FROM tablename
Example 3: return columns from table sql
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS -- INFORMATION_SCHEMA is an ANSI-standard (American National Standard Institute) set of read-only views which provide information about all of the tables, views, columns, and procedures in a database
WHERE TABLE_NAME = N'Customers' -- "N" defines the subsequent string (the string after the N) as being in unicode
Example 4: select query in sql
SELECT column_name FROM table_name;
Example 5: select in select sql
SELECT column1 = (SELECT column-name FROM table-name WHERE condition), column-names FROM table-name WEHRE condition
Example 6: select in select sql
SELECT column-names FROM table-name1 WHERE value IN (SELECT column-name FROM table-name2 WHERE condition)