SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    mysql and or syntax issues

    Hi All,

    I have been google-ing for the proper syntax to use and this is as close as I can get yet it totally ignores the AND.

    I googled for a mysql search script and settled on this approach. Search was for cars and motorcycles that are published and not deleted.

    Code:
    SELECT * FROM products 
    WHERE title LIKE '%cars%' 
    OR descl LIKE '%cars%' 
    OR title LIKE '%motorcycles%' 
    OR descl LIKE '%motorcycles%' 
    AND (pub = '0' AND deleted IS NULL)
    Can someone show me the errors of my ways?

    Thanks
    What I lack in acuracy I make up for in misteaks

  2. #2
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT * FROM products
    WHERE ( title LIKE '%cars%'
    OR descl LIKE '%cars%'
    OR title LIKE '%motorcycles%'
    OR descl LIKE '%motorcycles%' )
    AND pub = '0'
    AND deleted IS NULL

  3. #3
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I can see the light now
    What I lack in acuracy I make up for in misteaks

  4. #4
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I hate being a noob, after working hours on this (I did learn something) I stumbled across Full-text which will meet my needs much better and will probably have more questions.

    Cheers
    What I lack in acuracy I make up for in misteaks


Bookmarks

Posting Permissions

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