Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Final Year Project SQL problem

  • 03-04-2014 10:06PM
    #1
    Closed Accounts Posts: 1,460 ✭✭✭


    This post has been deleted.


Comments

  • Registered Users, Registered Users 2 Posts: 8,987 ✭✭✭brevity


    When using like I'm pretty sure you have to use the % as wildcard either at the start or the end of the word you are searching for.

    I'd bring the AND statements above the other logic. Then filter on profession etc


  • Registered Users, Registered Users 2 Posts: 1,019 ✭✭✭carlmango11


    This is just off the top of my head but I think you might need an extra set of brackets around the OR clauses depending on how you want the statement to be interpreted. If I had to guess I'd say what's happening is that as soon as 1 of the 'OR' clauses if matched the rest of the WHERE section is ignored


  • Closed Accounts Posts: 1,460 ✭✭✭DipStick McSwindler


    This post has been deleted.


  • Registered Users, Registered Users 2 Posts: 6,131 ✭✭✭jhegarty


    try this:

    SELECT `Advert_ID`, `User_ID`, `Username` FROM adverts

    WHERE ((`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Ceptic' AND `Skill_Level_Needed` LIKE 'Proffessional')

    OR (`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Heating' AND `Skill_Level_Needed` LIKE 'Proffessional')

    OR (`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Sink' AND `Skill_Level_Needed` LIKE 'Proffessional'))
    AND User_ID = '16' AND Location_Country = 'Ireland' AND Location_City = 'Dublin' AND Active = 1


  • Closed Accounts Posts: 1,460 ✭✭✭DipStick McSwindler


    This post has been deleted.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,019 ✭✭✭carlmango11


    Guys I got it,A kind gentleman on Stackoverflow pointed out I had the Brackets placed wrong so the emphasis was on the wrong Statements. Heres thecorrect answer

    SELECT `Advert_ID`, `User_ID`, `Username` FROM adverts
    WHERE (
    (`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Ceptic' AND `Skill_Level_Needed` LIKE 'Proffessional')
    OR (`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Heating' AND `Skill_Level_Needed` LIKE 'Proffessional')
    OR (`Skill_Proffession_Needed` LIKE 'Plumbing' AND `Skill_Area_Needed` LIKE 'Sink' AND `Skill_Level_Needed` LIKE 'Proffessional')
    )
    AND `User_ID` = '16'
    AND `Location_Country` LIKE 'Ireland'
    AND `Location_City` LIKE 'Dublin'
    AND Active = 1


    Thank you all so much for your help I really appreciate it! :)

    That's exactly what I meant :(


  • Closed Accounts Posts: 1,460 ✭✭✭DipStick McSwindler


    This post has been deleted.


  • Closed Accounts Posts: 1,460 ✭✭✭DipStick McSwindler


    This post has been deleted.


Advertisement