Jump to content

Simple SQL query (if you know much about SQL anyway)


johnsmith153

Recommended Posts

I believe this is standard for SQL queries:

$sql = sprintf("SELECT Name FROM $tableName WHERE Name LIKE '%s'",mysql_real_escape_string($name));

 

However, I want to do this:

$sql = "SELECT Name FROM $tableName WHERE Name LIKE '%$name%'";

i.e I want to search the table and return values that contain the $name (as opposed to the first one which only returns exact matches).

 

 

How would I do the sprintf code that also includes the ability to search part of a value (ie the % before and after the value)?

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.