View Full Version : using the NOT operator to exclude fields

02-27-2007, 06:18 AM
Hi all,

I want to be able to select all fields from a table except certain fields.

I came across the NOT operator in the MySQL ref. manual, and I wanted to check about the syntax of that operator.

Would this syntax work:
SELECT NOT id1, id2, id3, id4 FROM table

Or would this work:
SELECT NOT id1, NOT id2, NOT id3, NOT id4 FROM table

If neither, what is the shortest way that would work? Thanks!

02-27-2007, 02:11 PM
Neither will work. You have to specify the exact columns you want from your table. Some people use SELECT * to select all columns but that should only be used for testing purposes.

You can't use the NOT operator to specify which columns you do/do not want.

02-28-2007, 12:00 AM
OK, thanks. I can still do it, it will just be a bit more code then. Thank you!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum