Jump to content

Select data from two tables at once


ShaolinF

Recommended Posts

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?

 

 

.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.