Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

MySQL WHERE Clause Help

DriedSponge
 Share

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

Desktop:

AMD Ryzen 7 3800X | MSI B450 TOMAHAWK MAX | G.Skill Trident Z RGB 32 GB DDR4-3600 | Gigabyte GeForce RTX 2080 SUPER 8 GB 

SK hynix Gold S31 500GB SSDSeagate Barracuda Compute 2 TB 7200RPM HDD | 1TB Samsung 860 EVO SSD | 3x Noctua NF-A14 PWM 140 mm 

Phanteks AMP 650 W 80+ Gold Certified Modular  | Phanteks Eclipse P300A Mesh Mid Tower | Windows 10 Home

Link to comment
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 comment
Share on other sites

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

Desktop:

AMD Ryzen 7 3800X | MSI B450 TOMAHAWK MAX | G.Skill Trident Z RGB 32 GB DDR4-3600 | Gigabyte GeForce RTX 2080 SUPER 8 GB 

SK hynix Gold S31 500GB SSDSeagate Barracuda Compute 2 TB 7200RPM HDD | 1TB Samsung 860 EVO SSD | 3x Noctua NF-A14 PWM 140 mm 

Phanteks AMP 650 W 80+ Gold Certified Modular  | Phanteks Eclipse P300A Mesh Mid Tower | Windows 10 Home

Link to comment
Share on other sites

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
 Share


×