我有两个表名课程和机构。 这是我的疑问:
CREATE TEMPORARY TABLE
IF NOT EXISTS temp AS (SELECT course_name, ins_name
FROM courses
where course_name='ACCA') ;
select institution.ins_name, address, contact, website,
email from institution join temp on institution.ins_name = temp.ins_name
这是我的php脚本:
<?php
session_start();
include('db_connect.php');
$sql="CREATE TEMPORARY TABLE
IF NOT EXISTS temp AS (SELECT course_name, ins_name
FROM courses
where course_name='ACCA') ;
select institution.ins_name, address, contact, website, email from institution join temp on institution.ins_name = temp.ins_name";
$result= mysqli_query($conn, $sql) or die("MySQL error: " . mysqli_error($conn));
while ($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['ins_name'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['contact'] . "</td>";
echo "<td>" . $row['website'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
echo "</table>"
?>
我无法弄清问题是什么。我得到的错误是:
MySQL错误:您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'select institution.ins_name,地址,联系方式,网站,来自机构j'的第6行的电子邮件附近使用正确的语法
我做错了什么?
答案 0 :(得分:2)
MySQL可选择允许在一个语句中包含多个语句 串。一次发送多个语句会减少客户端 - 服务器 往返但需要特殊处理。
必须执行多个语句或多个查询
mysqli_multi_query()
。声明的个别陈述 字符串用分号分隔。然后,返回所有结果集 必须提取已执行的语句。
或者,只需触发两个查询。
答案 1 :(得分:1)
每个查询都必须单独执行。 Input.GetKey()
和keycodes
是两个不同的查询,因此首先您需要为using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed = 80.0f; // Code for how fast the ball can move. Also it will be public so we can change it inside of Unity itself.
public Rigidbody player1RB; //Player 1 Rigidbody
public Rigidbody player2RB; //Player 2 Rigidbody
//Player 1 Code with aswd keys
void Player1Movement()
{
if (Input.GetKey(KeyCode.A))
{
player1RB.AddForce(Vector3.left * speed);
}
if (Input.GetKey(KeyCode.D))
{
player1RB.AddForce(Vector3.right * speed);
}
if (Input.GetKey(KeyCode.W))
{
player1RB.AddForce(Vector3.forward * speed);
}
if (Input.GetKey(KeyCode.S))
{
player1RB.AddForce(Vector3.back * speed);
}
}
//Player 2 Code with arrow keys
void Player2Movement()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
player2RB.AddForce(Vector3.left * speed);
}
if (Input.GetKey(KeyCode.RightArrow))
{
player2RB.AddForce(Vector3.right * speed);
}
if (Input.GetKey(KeyCode.UpArrow))
{
player2RB.AddForce(Vector3.forward * speed);
}
if (Input.GetKey(KeyCode.DownArrow))
{
player2RB.AddForce(Vector3.back * speed);
}
}
// Update is called once per frame
void FixedUpdate()
{
Player1Movement();
Player2Movement();
}
}
调用create
,然后为select
调用mysqli_query
答案 2 :(得分:0)
每列都需要别名:
select institution.ins_name, institution.address, institution.contact, institution.website, institution.email from institution join temp on institution.ins_name = temp.ins_name";