Hello all ! Need a little help here. Is there a way to "translate" variables/field names in an SQL statement?
I need to compare the "content" of two database fields that are in different tables. The trick, though, is that I need to join two fields together (as a string) before I compare it. For example: Table 1 has a field named username, with the following values: id | username | first_name | last_name 1 | prgn/jason | jason | x 2 | falcon/paul | pual | wood *The username in table is composed of the user's domain name and login name. Those fields are separated in table 2. Like Table 2 id | username | domain | first_name | last_name 1 | paul | falcon | paul | wood 2 | jason | prgn | jason | x * the data is rearranged, but it's the same. Now, I need to compare the values from table 2 to table 1. That is, I need to find if table1.username = table2.domain/table2.username is true. There lies my problem. How do I get mysql to translate: ... where table.username = 'table2.domain/table2.username' into ...where 'prgn/jason' = 'prgn/jason' and not into ...where 'prgn/jason' = 'prgn' / 'jason' // division. That is, I need it to compare 'prgn/jason' (from table1.username) to the string representation, of the values of table2.domain/table2.username (i.e. prgn/jason) and not read it as 'table2.prgn' divided by 'table2.username' ? I have the following code: " select * from table1 t1, table 2 t2 where t1.username = 't2.domain/t2.username' " ** how do I concatenate the two values, to compare it to that of table 1. i.e. prgn/jason = prgn/jason and not 'prgn/jason' = 'prgn' divided by 'jason'? Please help. -john -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php