Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Mysql Query with possible join required ?

    Hi,

    I have a query:

    SELECT DISTINCT suburb FROM location WHERE city='Auckland' ORDER BY suburb ASC

    This basically pulls data from the Suburb column when the City Column has Brisbane next to it.

    Now what I'd like to do Is have another table with location data (like city and suburb above) in it as well as actual product data and it's called services.

    Now I'd like to be able to run the above query but only return the suburbs that have matching suburbs in the services table, hence removing suburbs I don't actually have data for.


    Table location
    Country, Language ID, ISO2, Suburb, Town/City, Region, Postcode, Road Name, Latitude, Longitude, TZ, UTC, DST,
    NZ, EN, NZ-AUK, East Tamaki, Auckland, Auckland, 2016, Aaronville Way, -36.9391594, 174.909317, Pacific/Auckland, UTC+12, Y,
    NZ, EN, NZ-AUK, Mt Roskill, Auckland, Auckland, 1034, Bogan Way, -34.871287, 172.766999, Pacific/Auckland, UTC+12, Y,

    Table services
    sid, Bussines Name, Address, Website, Email, Phone, Service, Category, Sub category, Sub category type, Sub category type Description, Price, Region, City, Suburb, Postcode,
    1 Balls'R'Us, Level 1 Unit 1 10 Example Drive, http://www.example.com/, info@example.com, (09) 555 1234, Ball, Small, Bouncy, Large, 0, Auckland, Auckland, East Tamaki, 2016,


    So when I execute my Select statement I would only expect to see the one suburb "east tamaki" and not "mt roskill" as the output.

    Hope that makes sense..

    Cheers
    Last edited by Apostle4; 11-12-2013 at 06:22 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,211
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    Show the full design of BOTH tables.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jan 2013
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Original post updated with table data.

  • #4
    New Coder
    Join Date
    Jan 2013
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok have found the answer elsewhere..


  •  

    Posting Permissions

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