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
https://forums.phpfreaks.com/topic/63191-solved-query-a-db/
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
https://forums.phpfreaks.com/topic/63191-solved-query-a-db/#findComment-314940
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
https://forums.phpfreaks.com/topic/63191-solved-query-a-db/#findComment-315011
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.