If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL query join problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-03, 13:03
decrypto decrypto is offline
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 2
Post MySQL query join problem

I have a problem writing the SQL manually.

I´m trying to get the same output in MySQL.

that i´m getting here -> http://www.webdecor.dk/gfx/db_tbl.gif

But the SQL you here is generated by SQL Server and it doesnt work in MySQL.

Can someone tell me how to do it, I have been trying and trying...
Reply With Quote
  #2 (permalink)  
Old 12-15-03, 17:12
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: MySQL query join problem

You need to specify the ON clause of the join syntax before specifying a new join, if I am not mistaken. For instance, instead of using
Code:
RIGHT OUTER JOIN theater INNER JOIN row...
You need to use:
Code:
RIGHT OUTER JOIN theater ON eventshow.Theater_ID = theater.IDNR
INNER JOIN row ON row.Theater_ID = theater.IDNR
The table structure shown in the diagram does not look optimal. You probably want to rethink the query. Maybe something like this:

Code:
SELECT ...
FROM seat_reservation
INNER JOIN status ON status.IDNR = seat_reservation.status_id
RIGHT JOIN seat ON seat_reservation.seat_id = seat.IDNR
INNER JOIN row ON seat.row_id = row.IDNR
INNER JOIN theater ON row.theater_ID = theater.IDNR
INNER JOIN eventshow ON theater.IDNR = eventshow.theater_id
WHERE eventshow.IDNR = 1 AND eventshow.theater_id = 1;
Reply With Quote
  #3 (permalink)  
Old 12-17-03, 07:52
decrypto decrypto is offline
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 2
Got it fixed

Hi there, I got it fixed.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On