Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Final Year Project SQL problem

Options
  • 03-04-2014 11:06pm
    #1
    Closed Accounts Posts: 1,460 ✭✭✭


    This post has been deleted.


Comments

  • Registered Users Posts: 8,518 ✭✭✭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 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 Posts: 6,440 ✭✭✭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 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