----- Original Message ----- From: "Ferhat BINGOL" <[EMAIL PROTECTED]> To: "mysql" <[EMAIL PROTECTED]> Sent: Thursday, October 14, 2004 8:24 AM Subject: a puzzle (at least for me)
> > Hi, > > I could not do this... > > TABLE1 > ID NAME price > ----- -------- ------ > 1 1stname 34 > 2 2ndname 0 > > > TABLE2 > date 1stname 2ndname > ------- ------- ------- > 20041023 23.5 12.3 > > > > As a result I want to get out raws something like this... > > > 1 34 1stname 23.5 > 2 0 2ndname 12.3 > > What is the SQL syntax for this puzzle...?? > > Or is it possible? > You obviously need to do a join to combine any two (or more) tables in MySQL. I assume you know that, although you haven't shown us any of your attempts at making this query work so I can't be sure. Your desired result is clearly trying to join one table to another when a data value in one of the tables is the same as a *column name* in the other table. You want MySQL to somehow realize that the data value '1stname' in TABLE1 needs to be replaced with the data values in the '1stname' COLUMN of TABLE2. That simply isn't possible. Joins are based on the idea that a piece of data in one table matches a piece of data in the other table, not a column name in the second table. The problem here is your data model, not SQL syntax. Unfortunately, I haven't got the foggiest idea what your data represents so I can't suggest a better way to organize your data. Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]