Jump to content

Recommended Posts

Ok here goes:

I have a php page with Mysql that is using a left join. ( That works correctly.)

 

$query_partdata = "SELECT electrical_BOM.itemnumber,electrical_BOM.description, electrical_BOM.code,  parts.partnumber, parts.parttype, parts.package , parts.manufacturer, parts.screenlevel, parts.quallevel, parts.totaldoselevel, parts.seulevel, electrical_BOM.quantity, electrical_BOM.whereused, parts.parnumber
From electrical_BOM LEFT JOIN parts ON electrical_BOM.itemnumber = parts.itemnumber";

Ok so I have two tables, electrical_BOM and parts

Per the LEFT JOIN function all of the records from electrical_BOM are displayed after being joined with certain fields from parts.(This works ok, I output it to the screen)

 

However I would like to somehow use a WHERE or other technique in which I only obtain the records in electrical_BOM when the field  "code" (Which is in electrical_BOM) is equal to the number 2 or 3.

 

I dont know how to use the LEFT JOIN in conjunction with the WHERE. Maybe there is a better way of doing this than using a LEFT JOIN?

Thanks

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/94019-left-join-and-where/
Share on other sites

<?php
$query_partdata = "SELECT electrical_BOM.itemnumber,electrical_BOM.description, electrical_BOM.code,  
                    parts.partnumber, parts.parttype, parts.package , parts.manufacturer, 
                    parts.screenlevel, parts.quallevel, parts.totaldoselevel, parts.seulevel, 
                    electrical_BOM.quantity, electrical_BOM.whereused, parts.parnumber
                   FROM electrical_BOM 
                        LEFT JOIN parts ON electrical_BOM.itemnumber = parts.itemnumber
                   WHERE electrical_BOM.code IN (2,3)";      

Link to comment
https://forums.phpfreaks.com/topic/94019-left-join-and-where/#findComment-482097
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.