shaun thornburgh wrote:
I am trying to get all field names from my table that begin with
letter X or Y, however the following statement and many variations I
have tried produce an error:

SHOW COLUMNS FROM TABLE LIKE "X%" OR LIKE "Y%"

According to the manual, the pattern for SHOW COLUMNS is:

  SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE 'pattern']

There is no WHERE clause or expression evaluation here, to achieve what you want you must issue the statement twice:

SHOW COLUMNS FROM tbl_name LIKE "X%";
SHOW COLUMNS FROM tbl_name LIKE "Y%";

<URL: http://dev.mysql.com/doc/mysql/en/SHOW_COLUMNS.html >

You didn't ask, but a shorter way to write this is using the DESCRIBE command, which can be abbreviated to DESC:

DESC tbl_name "X%";
DESC tbl_name "Y%";

<URL: http://dev.mysql.com/doc/mysql/en/DESCRIBE.html >

--
Roger


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to