php - select from multipe tables join return null if columns not match -



php - select from multipe tables join return null if columns not match -

i'm trying create mysql query specifying columns userid = x , others userid = y.

my problem (what happening) if selected column user x doesn't match content same column user y, query homecoming null (as have check-if declare variables , variables else beingness printed... ).

i need select 3 tables: members, friends , account_type:

1º members.status (and other columns such name, month1-12 , photo) members.id = $_get['id'] 2º account_type.type need compare members.acc_type members.id = $_session['user_id']. 3º friends.cashed_month1-12 (and column total) friends.friendid = $_get['id']

how can specify id belongs each columns?

i don't know how create in 1 query, can create separately...

actually, have:

select friends.*, members.*, account_type.* members inner bring together friends on friends.friendid = members.id inner bring together account_type on account_type.type = members.acc_type friends.friendid = ? , members.acc_type = ?")) { $stmt->bind_param('isi', $_get['id'], $_session['acc_type'];

from 2º have problem, select column , need specify id or row, because there many accounts same acc_type specifying id should work if connected user have different acc_type friend account. mean, thought is: every user, no matter acc_type is, can have friends different acc_types.

i tested, if connected user , $_get['id'] user have same acc_type, works fine, if alter acc_type connected user, query won't work.

thanks in advance!

finally got query works (it took me couple of hours), reply may serve others helped me:

select members.*, account_type.*, friends.*, membersf.* members inner bring together account_type on members.acc_type = account_type.type inner bring together friends on friends.userid = members.id inner bring together members membersf on membersf.id = friends.friendid members.acc_type = ? , friends.userid = ? , membersf.id = ? $_session['acc_type'], $_session['user_id'], $_get['id']

some explain:

inner bring together account_type on members.acc_type = account_type.type

this homecoming acc_type connected user , able print columns corresponding account_type (you can add together many columns, apart bonus).

inner bring together friends on friends.userid = members.id

here, homecoming columns in table corresponding userid.

inner bring together members membersf on membersf.id = friends.friendid

and finally, homecoming columns members corresponding id, in case friend id.

that's :)

php mysql

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -