如何在不同数据库表的一个页面中显示数据

时间:2016-10-14 14:27:53

标签: php html mysql sql

我有2个表是事件,场地的数据库 事件表包含eventTitle,eventID和venueID 场地表保存场地ID,场地名称和位置 这是我的SQL查询。

$sqlEvent = "SELECT * FROM te_events , te_venue ORDER by eventTitle
                WHERE te_events.venueID = te_venue.venueID
                 ";

但错误u have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE te_events.venueID = te_venue.venueID' at line 2
我想要做的是使用PHP脚本在页面中显示venuename和位置。 删除'where'子句后,一切正常,但事件会重复。

2 个答案:

答案 0 :(得分:2)

序列错误的子句

"SELECT * FROM te_events , te_venue 
  WHERE te_events.venueID = te_venue.venueID
ORDER by eventTitle  ";

中选择where clasue在订单之前

答案 1 :(得分:1)

$sqlEvent = "SELECT * FROM te_events , te_venue WHERE te_events.venueID = te_venue.venueID ORDER by eventTitle  ";