我需要在查询中插入一个冗长的语句(见下文)。
$q =
'SELECT vh12915_fleet.systemHistory.systName, vh12915_space.stars.x, vh12915_space.stars.y
FROM vh12915_fleet.systemHistory
INNER JOIN vh12915_space.stars
ON vh12915_fleet.systemHistory.systName = vh12915_space.stars.name
WHERE vh12915_fleet.systemHistory.fleetName = "Fl"';
我提供的声明没有错误,因为它已经在phpMyadmin中测试过并且有效。
但是,当放入脚本时会产生错误。
将冗长的语句放入查询的正确方法是什么? 为什么这个确切的语句在phpMyAdmin中有效,而不在脚本中?
答案 0 :(得分:1)
使用php脚本
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$q = '
SELECT vh12915_fleet.systemHistory.systName,
vh12915_space.stars.x,
vh12915_space.stars.y
FROM vh12915_fleet.systemHistory
INNER JOIN vh12915_space.stars
ON vh12915_fleet.systemHistory.systName = vh12915_space.stars.name
WHERE vh12915_fleet.systemHistory.fleetName = "Fl"';
$result = $mysqli->query($q);
// use result