hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : php mysql select statement problem
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

php mysql select statement problem

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-19-2006, 01:57 PM
housefire housefire is offline
Junior Guru Wannabe
 
Join Date: Mar 2006
Posts: 84

php mysql select statement problem


ive got a mysql database that has 4 tables.

Location, City, State and Country

Im trying to do a list all of Locations via the following:

SELECT Locations.Street, City.CityName, State.StateName, Locations.PhoneNumber, Country.CountryName FROM Locations, City, State, Country WHERE Locations.CityID=City.CityID AND City.StateID=State.StateID AND State.CountryID=Country.CountryID


Basically Locations looks like:

+-------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+----------------+
| LocationID | int(11) | | PRI | NULL | auto_increment |
| Street | text | | | | |
| CityID | int(11) | | | 0 | |
| PhoneNumber | text | | | | |
| Email | text | | | | |
+-------------+---------+------+-----+---------+----------------+


City is:

+----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+----------------+
| CityID | int(11) | | PRI | NULL | auto_increment |
| CityName | text | | | | |
| StateID | int(11) | | | 0 | |
+----------+---------+------+-----+---------+----------------+


State is:

+-----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+----------------+
| StateID | int(11) | | PRI | NULL | auto_increment |
| StateName | text | | | | |
| CountryID | int(11) | | | 0 | |
+-----------+---------+------+-----+---------+----------------+


and country:

+-------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+----------------+
| CountryID | int(11) | | PRI | NULL | auto_increment |
| CountryName | text | | | | |
+-------------+---------+------+-----+---------+----------------+



Anyone know what im doing wrong with my select statement?

Reply With Quote


Sponsored Links
  #2  
Old 04-19-2006, 02:13 PM
NorthWest NorthWest is offline
WHT Addict
 
Join Date: Jun 2004
Posts: 105
Try This:

Code:
SELECT Locations.Street, City.CityName, State.StateName, Locations.PhoneNumber, Country.CountryName, Locations.CityID, City.CityID, City.StateID, State.StateID, State.CountyID, County.CountyID FROM Locations, City, State, Country WHERE Locations.CityID=City.CityID AND City.StateID=State.StateID AND State.CountryID=Country.CountryID

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Irish Web Host Blacknight Offers .CO Domain Extensions Web Hosting News 2012-05-31 16:54:14
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Web Hosting Software Firm CloudLinux Releases CloudLinux OS Version 6.1 Web Hosting News 2011-09-13 14:08:49
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43
Gazzang Data Encrytion Solution Adds Support for CloudLinux Platform Web Hosting News 2011-06-30 18:54:10


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?