mysql select specific columns code example
Example 1: get table which have specific columns in mysql
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';
Example 2: mysql select all columns and specific fields as
SELECT mytable.*, column20 AS Customer, column11 FROM mytable
SELECT column11, column20 AS Customer, mytable.* FROM mytable
Example 3: mysql query select more columns
mysql> SELECT name, birth FROM pet;
+
| name | birth |
+
| Fluffy | 1993-02-04 |
| Claws | 1994-03-17 |
| Buffy | 1989-05-13 |
| Fang | 1990-08-27 |
| Bowser | 1989-08-31 |
| Chirpy | 1998-09-11 |
| Whistler | 1997-12-09 |
| Slim | 1996-04-29 |
| Puffball | 1999-03-30 |
+