mysql - SELECT DISTINCT with INNER JOIN -


hello all,
this sound simple i'm having problem here.

there tables:

table_a ta_id | ta_user | ta_hour | ta_date 

and

table_b tb_id | tb_name | tb_adress 

here query:

$sql = mysql_query("select                      distinct ta_user                      table_a                      inner join table_b on table_b.id = table_a.ta_user                      ta_date '%$vardate%'                      order ta_user asc "); 

when run while loop in array tb_name shuld print cause inter join dosen't work.

any ideas ?

it appears me have multiple table records given table b entity, right?

by way, column names horrible...table_b.id = table_a.ta_user???? how examining database supposed know relationship exists? that's beside point.

anyway, guess you're trying return table b entities have records in table_a given date?

if so, distinct should work you. i'd use group instead because it's faster. should want, if understand correctly.

select distinct table_b.tb_name     table_a          inner join table_b             on table_b.tb_id = table_a.ta_user     ta_date '%$vardate%'     order ta_user asc; 

and, @gordon linoff says above, date field suspicious. idea there seems appropriate me.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -