Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde,
Gostaria de uma ajuda para criar uma tabela temporaria em um banco de dados mysql, o código a baixo que vou postar funciona quando inserido no mysql, mais quando utilizo o php para fazer essa tare da erro .
$sql = "
DROP TABLE IF EXISTS teste;
CREATE TEMPORARY TABLE teste ( user_id int(10), qtd_words_use int(10), qtd_words_by_cluster int(10) );
INSERT INTO teste (user_id, qtd_words_use, qtd_words_by_cluster)
(
SELECT
al.user_id
, COUNT(DISTINCT pwr.word_id ) AS qtd_tags_use
, (
SELECT
COUNT(*)
FROM
clusters_profiling_words cpw
WHERE
cpw.cluster_id = 1
)AS qtd_tags
FROM
profiling_words_related pwr
JOIN actions a ON a.area_id IN(SELECT a.action_id FROM actions a WHERE a.area_id = pwr.area_id)
JOIN actions_log al ON al.content_id = pwr.content_id AND al.action_id = a.action_id
JOIN users u ON u.user_id = al.user_id
WHERE
pwr.word_id IN( SELECT cpw.word_id FROM clusters_profiling_words cpw WHERE cpw.cluster_id = 1 )
GROUP BY
al.user_id
)
UNION ALL
(
SELECT
upw.user_id
, COUNT(DISTINCT upw.word_id ) AS qtd_tags_use
, (
SELECT
COUNT(*)
FROM
clusters_profiling_words cpw
WHERE
cpw.cluster_id = 1
)AS qtd_tags
FROM
users_profiling_words upw
JOIN users u ON u.user_id = upw.user_id
WHERE
upw.word_id IN( SELECT cpw.word_id FROM clusters_profiling_words cpw WHERE cpw.cluster_id = 1 )
GROUP BY
upw.user_id
)
;
SELECT
user_id
,SUM(qtd_words_use) AS qtd_words
,qtd_words_by_cluster";
$rs = mysql_query($sql) or die(mysql_error());
o seguinte erro ocorre na pagina
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 '; CREATE TEMPORARY TABLE teste ( user_id int(10), qtd_words_use int(10), qtd_wo' at line 1
vlwss ai
Carregando comentários...