3
A
回答
2
向一个PostgreSQL的查询,您必须使用“
当你在PHP中生成一个查询,你可以使用“或”
"select * from table where id = 'me'"
或
'select * from table where id = \'me\''
4
Postgres中的字符串文字是用单引号定义的。双引号用在标识符周围。所以下面的查询是有效的。
SELECT "id", "name" FROM my_table WHERE "name" = 'Brian'
然而,你联系,你问单引号'VS双引号“在PHP中的字符串,而不是Postgres的查询答案判断。
同为普通字符串,一双引号括起来将插值变量,而在单引号的字符串将有你把什么英寸
$my_var = "noob";
echo "This is a test string, $my_var\nGot it?";
>> This is a test string, noob
>> Got it?
echo 'This is a test string, $my_var\nGot it?';
>> This is a test string, $my_var\nGot it?
+0
我不知道你的例子是否适用于PHP PG查询,因为它们是在不同的环境是不在查询中。你的答案也与维塔利的答案相冲突。 – 2009-08-29 12:08:18
相关问题
- 1. ,Postgres的查询
- 2. PHP和Postgres查询问题
- 3. 保存,Postgres的查询在PHP变量
- 4. ,Postgres的查询optmization
- 5. 查询来检查的Postgres
- 6. Postgres在postgres查询上的实时查询事件
- 7. Slow Postgres查询
- 8. 更新查询php postgres无故失败
- 9. php postgres pdo提取并选择查询
- 10. Postgres的条件查询 - 为
- 11. ,Postgres的查询错误
- 12. 优化我的postgres查询
- 13. SQL递归查询的Postgres
- 14. Postgres的SQL递归查询
- 15. Postgres的 - 两个查询
- 16. Postgres复杂的SQL查询
- 17. Postgres的DISTINCT查询问题
- 18. 如何查询postgres的UUID
- 19. 查询Postgres的SQL JSON表
- 20. 的Postgres,串子查询
- 21. Postgres的时期查询
- 22. 查询Postgres的对象
- 23. postgres缓存我的查询?
- 24. 空栏或空字段检查在rails中的postgres查询
- 25. Postgres查询优化
- 26. Laravel/Postgres db查询?
- 27. 优化postgres查询
- 28. Postgres,nodejs SELECT查询
- 29. 查询新的Django的/的Postgres DateRangeField
- 30. 将postgres查询转换为django查询
**哪一个是正确的?**#1'id = $ 1'或#2'id ='$ 1'' – 2009-08-29 12:12:12
@Masi:#1是正确的 - 不要将查询参数放在引号中。 – 2009-08-29 14:50:58
@Luc M:您可以在PostgreSQL查询中使用“,但它适用于分隔标识符,而不是字符串文字。 – 2009-08-29 14:54:31