如何创建对 mysql 数据库的有效查询?
如何添加WHERE visible = 1
到此查询
SELECT *
FROM photographs
WHERE caption like %colname% or caption_2 like %colname%
SELECT *
FROM photographs
WHERE caption LIKE '%colname%'
OR caption_2 LIKE '%colname%'
AND visible = 1
我认为我在代码中做错了,因为有些东西不起作用:) 显示所有结果
mysql_select_db($database_Photo_con, $Photo_con);
$query_rsPhoto = sprintf("SELECT * FROM photographs WHERE caption LIKE %s OR caption_2 LIKE %s AND visible = 1 ", GetSQLValueString("%" . $colname_rsPhoto . "%", "text"),GetSQLValueString("%" . $colname_rsPhoto . "%", "text"));
$query_limit_rsPhoto = sprintf("%s LIMIT %d, %d", $query_rsPhoto, $startRow_rsPhoto, $maxRows_rsPhoto);
$rsPhoto = mysql_query($query_limit_rsPhoto, $Photo_con) or die(mysql_error());
$row_rsPhoto = mysql_fetch_assoc($rsPhoto);