Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using the NOT operator to exclude fields

    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!

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    New Coder
    Join Date
    Apr 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, thanks. I can still do it, it will just be a bit more code then. Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •