Jump to content

[SOLVED] Query a DB


ainoy31

Recommended Posts

I have two tables:

 

Table 1:

(carrier)

carrier_ID int(16) NOT NULL auto_increment,

carrier_name varchar(64) NOT NULL,

carrier_phone varchar(12) NOT NULL,

carrier_email varchar(32) NOT NULL,

 

PRIMARY KEY (carrier_ID)

 

Table 2:

(flight_schedule)

 

fs_ID int(16) NOT NULL auto_increment,

carrier_ID int(16) NOT NULL,

fs_date varchar(32) NOT NULL,

fs_deptport varchar(32) NOT NULL,

fs_destport varchar(32) NOT NULL,

 

PRIMARY KEY (fs_ID),

FOREIGN KEY (carrier_ID) REFERENCES carrier (carrier_ID)

 

I am having an issue with this query working:

 

$sql = "SELECT * FROM carrier c,  flight_schedule fs WHERE c.carrier_ID = fs.carrier_ID AND fs.fs_date = '$reqDate' AND fs.fs_deptport = '$reqDeptAirport' AND fs.fs_destport = '$reqDestAirport'";

 

Any suggestions would be appreciated.  ty.  Ainoy

Link to comment
Share on other sites

i'm going to guess that it's because you're not specifying the table in the field list (even though it's just a *), despite having multiple tables in your FROM section:

 

$sql = "SELECT c.*, fs.* FROM carrier c,  flight_schedule fs WHERE c.carrier_ID = fs.carrier_ID AND fs.fs_date = '$reqDate' AND fs.fs_deptport = '$reqDeptAirport' AND fs.fs_destport = '$reqDestAirport'";

Link to comment
Share on other sites

u know what the problem was.  nothing to do with the query statement.  the date field was not in the same format.  the DB had a date type and the date entered was not in the date type format.  i found out by comapring one thing at a time and there u go.  much appreciation man.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.