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

quick mysql question

  • 01-04-2008 1:58pm
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    hi

    i have a property listing site im working on- i want to get the city details ffrom the city table (it_city) but i only want to show the ones that have entries in the property table (it_prop)

    how do i go about this?

    SELECT c.* FROM it_city AS c RIGHT JOIN .....


    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 568 ✭✭✭phil


    i have a property listing site im working on- i want to get the city details ffrom the city table (it_city) but i only want to show the ones that have entries in the property table (it_prop)

    RIGHT JOIN matches up the two tables even if there are no matches, so that's not what you want (Bear in mind that LEFT JOIN is pretty much the same thing).

    What you're probably looking for is an INNER JOIN.
    SELECT [...] FROM it_city INNER JOIN it_prop ON it_city.id=it_prop.id WHERE [...]
    

    That's an example where the `id` field is common to both. Rename appropiately.

    Phil.


Advertisement