SQL代码:
SELECT id, album_date AS timestamp, CONCAT((SELECT detail_value
FROM people_db.user_details_tbl WHERE detail_field = 'first_name' AND user_id = pictures_db.albums.owner), ' uploaded pictures!') AS title_html
FROM pictures_db.albums
WHERE id IN
(SELECT DISTINCT(album_id)
FROM pictures_db.album_pics
WHERE pic_id IN
(SELECT DISTINCT(picture_id)
FROM pictures_db.picture_access_tbl
WHERE grantee_group_id IN
(SELECT group_id
FROM people_db.group_membership_tbl
WHERE member_id = '2'
)
)
);
PHP代码:
$albums_sql = mysql_query("SELECT id, album_date AS timestamp, CONCAT((SELECT detail_value
FROM people_db.user_details_tbl
WHERE detail_field = 'first_name' AND user_id = pictures_db.albums.owner), ' uploaded pictures!') AS title_html
FROM pictures_db.albums
WHERE id IN (
SELECT DISTINCT(album_id)
FROM pictures_db.album_pics
WHERE pic_id IN (
SELECT DISTINCT(picture_id)
FROM pictures_db.picture_access_tbl
WHERE grantee_group_id IN (
SELECT group_id
FROM people_db.group_membership_tbl
WHERE member_id = '2'
)
)
)") or die(mysql_error());
运行PHP时,错误是:表'pictures_db.albums'不存在
我尝试以同一个用户身份执行,重新授予所有权限,甚至刷新权限。适用于shell,而不是PHP。 有什么想法吗?
答案 0 :(得分:1)
错误信息非常明确:MySQL看到数据库pictures_db而不是表专辑。
这可能是由于权限,但您似乎已经彻底检查过了。
另一个可能的原因是您在PHP中使用的连接字符串指向的是与您在命令行中使用的数据库实例不同的数据库实例。也许连接字符串仍指向不同的环境,例如DEV,但您是在QA中还是指向数据库的旧测试版本?
答案 1 :(得分:0)
在运行查询之前,您是否致电mysql_select_db()
?
mysql_select_db('pictures_db');