Jump to content
ajoo

mysql temporary table result to identify rows in the table

Recommended Posts

Hi all,

Does the statement

"CREATE TEMPORARY TABLE  temptab as  SELECT ... " 

provide some sort of a return value to check the null/number of rows in that table?

Running the same in phpadmin definitely gives the number of rows affected but i don't know how to tap into that value. I tried using the

$stmt->bind_result($count); 

after executing the query thinking it might be the same as the Select query but that returns no value while my table has about 7 rows generated.

If someone can show how, if the value can be retrieved.

Thanks.

 

Share this post


Link to post
Share on other sites

No sir, I hadn't.

?Thank you Guru Barand !!

Edited by ajoo

Share this post


Link to post
Share on other sites

SIr,

The following query however fails to give the number of affected rows.

SELECT 
table_A.uid,
table_A.pole,
table_A.act as Status
FROM
table_A

UNION

SELECT
table_B.uid,
table_B.pole,
table_B.confirm_A as status
FROM table_B

UNION

SELECT
table_C.uid,
'User' as pole,
(table_C.confirm_A + table_C.confirm_B) as status
FROM table_C;

There are about 9 rows that are actually formed so I wonder if that is the same as rows affected. Is there a way to find the number of rows formed from the above query ?

Presently I encompass the above query with an additional

SELECT COUNT(uid) FROM
{




}bb;

which provides the rows that are available as 9.

Running the 1st query is faster in this case. I was wondering if I could do without the COUNT(uid) thingy !

Thank you.

 

Share this post


Link to post
Share on other sites

Your code smells of a bad database design. How about telling us why you are repeating the same data columns in multiple tables.

Share this post


Link to post
Share on other sites

There won't be any "affected rows". It is not an update, delete or insert query.

Edited by Barand
  • Like 1

Share this post


Link to post
Share on other sites

Hi Benanamen !

Thanks for the response. Please bear with me for a day or so while I am doing a quick run through of my code. I'll come back and revert shortly.

Meanwhile, here's a link, in case you would like to check out the near same discussion earlier on this topic.

https://forums.phpfreaks.com/topic/301981-query-woes-confused/

Sorry for this delay.

Thanks.

Edited by ajoo

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.