SQL Query Join Table expression

Results 1 to 2 of 2

Thread: SQL Query Join Table expression

  1. #1
    Join Date
    Dec 1969

    Default SQL Query Join Table expression

    Hi,<BR>I am trying to retrieve dat from an Access DB and display it on a website through ASP. I am trying to retrieve data from 2 tables in the same database namely Flights and FlightBookings. I either get a syntax error or syntax error in join expression. But I need to only retrieve records that have equal Flight numbers in both tables.<BR>Here is some of my code but its dreadfully wrong I know, I&#039;m not too good at sql.<BR>Dim dbConn, dbRS, sql_showflight<BR> Set dbConn = Server.CreateObject("ADODB.Connection") <BR> Set dbRS = Server.CreateObject("ADODB.Recordset")<BR> dbConn.Open "Flight2a"<BR><BR> dbRS.Open "Flights", "DSN=Flight2a"<BR> Set Session ("Flight2_dbConn") = dbConn<BR><BR> &#039;sql_showflight = "SELECT * FROM Flights"<BR><BR>sql_showflight = "SELECT Flights.FlightNum, FlightBookings.PassNum, FlightBookings.FlightNum " &_<BR> "FROM Flights " &_<BR> "INNER JOIN (Flights INNER JOIN FlightBookings ON " _<BR> & "Flights.FlightNum = FlightBookings.FlightNum"_<BR> & "ORDER BY Flights.FlightNum"<BR><BR> Set dbRS = dbConn.Execute(sql_showflight)

  2. #2
    Join Date
    Dec 1969

    Default Missing space and other errors

    You only need than join in this case. There also was some missing spaces between keywords.<BR><BR>sql_showflight = "SELECT Flights.FlightNum, FlightBookings.PassNum, FlightBookings.FlightNum " &_ <BR>" FROM Flights " &_ <BR>" INNER JOIN FlightBookings ON " _ <BR>& " Flights.FlightNum = FlightBookings.FlightNum "_ <BR>& " ORDER BY Flights.FlightNum" <BR>

Posting Permissions

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