ShaolinF Posted August 30, 2008 Share Posted August 30, 2008 Hi Guys, Please take a look at the following two tables: CREATE TABLE user ( user_id integer auto_increment NOT NULL, first_name varchar(40) NOT NULL, is_active enum('0','1') DEFAULT '1', confirm_code int( NULL, PRIMARY KEY (user_id) ); CREATE TABLE credit_remaining ( credit_amount_id integer auto_increment NOT NULL, user_id integer NOT NULL, credit_amount numeric(8,2) DEFAULT '0.0', PRIMARY KEY (credit_amount_id), FOREIGN KEY (user_id) REFERENCES user(user_id) ); I want to select the user_id and first_name from the user table and credit_amount from the credit_remaining table. How can I do this in one statment? . Quote Link to comment Share on other sites More sharing options...
toplay Posted August 30, 2008 Share Posted August 30, 2008 Try something like this: select u.user_id, u.first_name, cr.credit_amount from `user` u join `credit_remaining` cr on cr.user_id = u.user_id where u.user_id = 1234 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.