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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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,628 ✭✭✭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,441 ✭✭✭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