Jump to content

Linking tables


dc_jt

Recommended Posts

Hi

I have 2 tables one called leads and one called status.

The leads table contains leads_id, reference_number, status_id

The status table contains status_id, status

Im running a while loop where i get all the information from the leads table, however because I store the status_id it is showing the status_id rather than the actual status i.e Live, New etc.

Therefore, how can I get it to show the actual status instead of the number?

I was thinking I may have to have another table called linkstatus which would contain linkstatus_id, leads_id and status_id.

Would this be the best way to do it and then what would I have to do??

Hope someone can help

Thanks
Link to comment
Share on other sites

Hi there,
You can use the JOIN statments(inner, or outre based on your requirements) to get the required information from both tables..example:

[code]SELECT leads.*, status.*
FROM leads
LEFT JOIN status
ON leads.status_id = status.status_id
WHERE (your where clause if any)[/code]
You can modify this statement to suite your requirements


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.