Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: Mysqpl while loop
02-11-2012, 07:30 AM #1
- Join Date
- Feb 2012
- Thanked 0 Times in 0 Posts
Mysqpl while loop
Hi, I am newbie
Can Some one help me to take out from my problem
I have two tables in database first allinfo and second string
in first table i have all the info about customer
and in second table i have two column first email<foriegn key> second string<as per moderators view>
I want to display all the records including string of second table dynamically
by while loop increment
can anyone solve my problem here ..
02-11-2012, 01:44 PM #2
- Join Date
- Aug 2008
- Czech Republic
- Thanked 34 Times in 33 Posts
Hi, let me clear the question:
You have two tables. The first one includes information about customers which are registered within your system. The second table contains two columns, the first one is email (I guess unique value) and second one is string (I guess text type). You want to display all records, am I right?
Could you please tell us how these two tables are connected with each other? I guess you will have email column in first table as well which should be used to link them together, am I right? Also could you please tell us why do you want to use loop and what are you trying to implement. May be there will be simper solution than query loop.
Waiting for your reply
02-11-2012, 10:23 PM #3
The only way to use a WHILE loop in MySQL is to create a stored procedure. I don't think that is what you need here. I think what you probably really want is a WHILE loop in PHP (or ASP or JSP or ... ) code.
If that's so, then it's easy:
Code:SELECT allinfo.*, string.string FROM allinfo LEFT JOIN string ON allinfo.email = string.email ORDER BY allinfo.??? [you choose]
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.