mysql - SQL values from two different tables -


okay have 2 tables in 1 database. 1 called accounts , 1 called settings. through one query fetch settings.positionx, settings.positiony , accounts.lastlogin. how go doing this?

without knowing conditions want can guess.. here need do.

if want records match in accounts , settings then:

select settings.positionx, settings.positiony, accounts.lastlogin settings  inner join accounts on settings.condition = accounts.condition 

if want records accounts (or settings) join matching records want left join / right join

select settings.positionx, settings.positiony, accounts.lastlogin settings  left join accounts on settings.condition = accounts.condition 

you can see visual representation of these joins here


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -