ajoo Posted January 14, 2019 Share Posted January 14, 2019 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 14, 2019 Share Posted January 14, 2019 Have you considered http://php.net/manual/en/mysqli.affected-rows.php 1 Quote Link to comment Share on other sites More sharing options...
ajoo Posted January 14, 2019 Author Share Posted January 14, 2019 (edited) No sir, I hadn't. ?Thank you Guru Barand !! Edited January 14, 2019 by ajoo Quote Link to comment Share on other sites More sharing options...
ajoo Posted January 19, 2019 Author Share Posted January 19, 2019 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. Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 19, 2019 Share Posted January 19, 2019 Your code smells of a bad database design. How about telling us why you are repeating the same data columns in multiple tables. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 19, 2019 Share Posted January 19, 2019 (edited) There won't be any "affected rows". It is not an update, delete or insert query. Edited January 19, 2019 by Barand 1 Quote Link to comment Share on other sites More sharing options...
ajoo Posted January 21, 2019 Author Share Posted January 21, 2019 (edited) 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 January 21, 2019 by ajoo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.