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
https://forums.phpfreaks.com/topic/34228-linking-tables/
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
https://forums.phpfreaks.com/topic/34228-linking-tables/#findComment-161010
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.