MySQL Forums
Forum List  »  Italian

Query Select Mysql
Posted by: Carlo D'Amelia
Date: April 06, 2015 02:23PM

Buona sera a tutti
Sto cercando di collegare due tabelle mediante query in questo modo:

settimana tab.1 tab.2
1 12345 12345
2 12345 23451
3 12345 34512

usando la sequente query

SELECT * FROM tab.1 AS a LEFT JOIN tab.2 AS c ON a.id+$i=c.id

dove $i è la settimana, quello che ottengo è il seguente risultato:

settimana tab.1 tab.2
1 12345 12345
2 12345 2345
3 12345 345

come faccio a far ripartire la conta dei record?

PS = avevo trovato questa soluzione:
I settimana SELECT * FROM tab.1 AS a LEFT JOIN tab.2 AS c ON a.id=c.id
II settimana SELECT * FROM tab.1 AS a LEFT JOIN tab.2 AS c ON a.id+1=c.id OR a.id=(SELECT max(id) FROM tab.1) AND c.id=(SELECT min(id) FROM tab.2)
ma le tabelle hanno 215 record e dovrebbero ciclare in automatico

Grazie in anticipo

Options: ReplyQuote


Subject
Views
Written By
Posted
Query Select Mysql
1833
April 06, 2015 02:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.