Jump to content

MySQL WHERE Clause Help

Go to solution Solved by elpiop,
16 minutes ago, DriedSponge said:

I know this is probably really simple but I'm having troubble figuring out how to select a row from a MySQL db where multiple columns equal a certain value. Here's what I have, I'm using PHP PDO:


$query = SQLWrapper()->prepare("SELECT postid,Images FROM ImagePost WHERE gid = :gid, Title = null, Category = null,Caption=null");

Any help would be apprciated! Thank you!

Use AND instead of comma

SELECT
  postid,
  Images
FROM
  ImagePost
WHERE
  gid = :gid
  AND Title = null
  AND Category = null
  AND Caption = null

 

I know this is probably really simple but I'm having troubble figuring out how to select a row from a MySQL db where multiple columns equal a certain value. Here's what I have, I'm using PHP PDO:

$query = SQLWrapper()->prepare("SELECT postid,Images FROM ImagePost WHERE gid = :gid, Title = null, Category = null,Caption=null");

Any help would be apprciated! Thank you!

Remember to quote or @mention others, so they are notified of your reply

AMD Ryzen 9 5950X | Arctic Liquid Freezer II 360 | MSI B450 TOMAHAWK MAX | G.Skill Trident Z RGB 32 GB DDR4-3600 | XFX Swift AMD Radeon RX 9070XT

Samsung 980 EVO Plus 2TB | SK hynix Gold S31 500GB SSD | Seagate Barracuda Compute 2 TB 7200RPM HDD | 1TB Samsung 860 EVO SSD | 2TB Samsung 970 EVO Plus NVMe SSD | 3x Phanteks T30-120

Corsair RM1000e 1000 W 80+ Gold Certified Modular PSU | Corsair 5000D Airflow Windows 11 Home

Link to comment
https://linustechtips.com/topic/1185202-mysql-where-clause-help/
Share on other sites

Link to post
Share on other sites

16 minutes ago, DriedSponge said:

I know this is probably really simple but I'm having troubble figuring out how to select a row from a MySQL db where multiple columns equal a certain value. Here's what I have, I'm using PHP PDO:


$query = SQLWrapper()->prepare("SELECT postid,Images FROM ImagePost WHERE gid = :gid, Title = null, Category = null,Caption=null");

Any help would be apprciated! Thank you!

Use AND instead of comma

SELECT
  postid,
  Images
FROM
  ImagePost
WHERE
  gid = :gid
  AND Title = null
  AND Category = null
  AND Caption = null

 

Link to post
Share on other sites

45 minutes ago, elpiop said:

Use AND instead of comma


SELECT
  postid,
  Images
FROM
  ImagePost
WHERE
  gid = :gid
  AND Title = null
  AND Category = null
  AND Caption = null

 

Perfect, thank you!

Remember to quote or @mention others, so they are notified of your reply

AMD Ryzen 9 5950X | Arctic Liquid Freezer II 360 | MSI B450 TOMAHAWK MAX | G.Skill Trident Z RGB 32 GB DDR4-3600 | XFX Swift AMD Radeon RX 9070XT

Samsung 980 EVO Plus 2TB | SK hynix Gold S31 500GB SSD | Seagate Barracuda Compute 2 TB 7200RPM HDD | 1TB Samsung 860 EVO SSD | 2TB Samsung 970 EVO Plus NVMe SSD | 3x Phanteks T30-120

Corsair RM1000e 1000 W 80+ Gold Certified Modular PSU | Corsair 5000D Airflow Windows 11 Home

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×