Merhaba ilginç bir sorun yaşıyorsanız im. />
Update: Gönderen bunun altında alma yorumlar im aynı anda birden fazla sorgular çalıştırmak için çalışırken bir sorun gibi görünüyor. Ben phpmyadmin yapıyor bu yana, o zaman tüm iyi olduğunu kabul etmişti. Nasıl bir çoklu sorgu çalıştırma hakkında gitmek nedir? Ben mysqli kullanıyorum? Ben mysql 5.x kullanıyorum ve mysqli kullanıyorum
Benim uygulama benim sorguyu çalıştıran im ve sorgu çalışmaz eğer ekrana echo. IS `nin hatası ile birlikte
When i run my application I get my query printed to the screen and this error.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE tmp_bulletins ADD INDEX (bb_id
); ' at line 13
When I copy the query which was echoed to the screen and run it in phpmyadmin it works fine every time. I have then tried taking the query that was echoed to the screen and running that on the database through my application and it doesn't work.
Bildiğim kadarıyla söyleyebilirim, aynı sorgu (benim ekrana yazdırılan bir) benim applcation yoluyla değil, phpmyadmin üzerinden çalışan, ancak.
Is there any reason that this might happen? Does phpmyadmin make some changes to a query before it runs it on the database?
İşte sorgu
CREATE TEMPORARY TABLE tmp_bulletins
SELECT {$table}.id AS bb_id,count(bb_replies.id) AS num_responses,bb_locations.title AS location,bb_locations.description AS location_description,bb_categories.title AS category,bb_categories.description AS category_description,Concat(users.first_name,' ',users.last_name) AS full_name,users.first_name AS first_name,users.last_name as last_name,users.id AS user_id,{$table}.title AS post_title,{$table}.content,{$table}.created_date,{$table}.rank
FROM `{$table}`
LEFT JOIN bb_locations ON {$table}.bb_locations_id = bb_locations.id
LEFT JOIN bb_categories ON {$table}.bb_categories_id = bb_categories.id
LEFT JOIN users ON {$table}.users_id = users.id
LEFT JOIN bb_replies ON {$table}.id = bb_replies.bbs_id
WHERE `bb_locations_id` IN ({$locations_csv}) AND `bb_categories_id` IN ({$categories_csv}) {$addWhere}
GROUP BY bb_id,location,location_description,category,category_description,first_name,last_name,user_id,post_title,content,created_date,rank
{$order} {$limit} ;
ALTER TABLE tmp_bulletins ADD INDEX (`bb_id`);
CREATE TEMPORARY TABLE tmp_ratings
SELECT bbs_id,
sum(CASE WHEN user_id = {$user_id} THEN like_dislike_id END) AS thisUsersRating,
SUM(CASE WHEN like_dislike_id = 2 THEN 1 ELSE 0 END) AS likes,
SUM(CASE WHEN like_dislike_id = 1 THEN 1 ELSE 0 END) AS dislikes
FROM bb_ratings
GROUP BY bbs_id;
ALTER TABLE tmp_ratings ADD INDEX (`bbs_id`);
SELECT * FROM tmp_bulletins
LEFT JOIN tmp_ratings on tmp_bulletins.bb_id = tmp_ratings.bbs_id;
Ve o (Konuştuğumuz gibi görünümünü düzenleme) üretir sorgu
CREATE TEMPORARY TABLE tmp_bulletins
SELECT bbs.id AS bb_id,count(bb_replies.id) AS num_responses,
bb_locations.title AS
location,bb_locations.description AS location_description,
bb_categories.title AS
category,bb_categories.description AS category_description,
Concat(users.first_name,' ',users.last_name) AS full_name,
users.first_name AS first_name,
users.last_name as last_name,users.id AS user_id,
bbs.title AS post_title,
bbs.content,bbs.created_date,bbs.rank FROM `bbs`
LEFT JOIN bb_locations ON bbs.bb_locations_id = bb_locations.id
LEFT JOIN bb_categories ON bbs.bb_categories_id = bb_categories.id
LEFT JOIN users ON bbs.users_id = users.id LEFT JOIN bb_replies ON bbs.id = bb_replies.bbs_id WHERE `bb_locations_id` IN (1,2) AND `bb_categories_id` IN (1,2)
GROUP BY bb_id,location,location_description,category,category_description,first_name,last_name,user_id,post_title,content,created_date,rank LIMIT 0,5; ALTER TABLE tmp_bulletins
ADD INDEX (`bb_id`);
CREATE TEMPORARY TABLE tmp_ratings
SELECT bbs_id, sum(CASE WHEN user_id = 1 THEN like_dislike_id END) AS thisUsersRating, SUM(CASE WHEN like_dislike_id = 2 THEN 1 ELSE 0 END) AS likes,
SUM(CASE WHEN like_dislike_id = 1 THEN 1 ELSE 0 END) AS dislikes FROM bb_ratings GROUP BY bbs_id;
ALTER TABLE tmp_ratings ADD INDEX (`bbs_id`);
SELECT * FROM tmp_bulletins LEFT JOIN tmp_ratings on tmp_bulletins.bb_id = tmp_ratings.bbs_id