| Author |
Topic  |
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 11:30:32
|
how can I explain, I have explained everything tell me what do you need
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 11:32:27
|
Then give us what we ask for!
What is the 5 with chicken and 7 with bread, meant to be?
Peter Larsson Helsingborg, Sweden |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 11:34:38
|
that is quantity of that food
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 11:55:40
|
SELECT DISTINCT f.food_name,
s.quantity,
f.food_price
FROM SeFOODS s
INNER JOIN FOODS f ON f.food_id = s.food_id
Peter Larsson Helsingborg, Sweden |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 12:16:19
|
thanks but again same results twice records
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 12:21:18
|
I think you are lying! It is impossible to get exact same result twice with my last query.
Please post the exact output of the query here.
Peter Larsson Helsingborg, Sweden |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 12:24:54
|
whattttttttttt ? tomorrow my boss will fire me If I don't do this why should I lie ? I am not crazy
OK , wait I will post some new info for you |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 12:28:31
|
I can't give you anything unless you post here what I ask for.
If you don't want to, or doesn't care to, good luck finding a new job. It is not my ass on the line here. If you don't want to listen and give us what we need and ask for, you better spend your time reading the classifieds.
Peter Larsson Helsingborg, Sweden |
Edited by - SwePeso on 10/29/2006 12:31:24 |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 12:44:45
|
look peter thisis my tables and some data

now easily I want pull out my selected foods from sefoods table by food name and its quantity just this result look like this :
Apple (37) Chiken (10)
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 12:55:24
|
This query have been posted to you many times already!
But... If you mean you want the text CONCATENATED, here is a modifed version.SELECT f.food_name + ' (' + cast(s.quantity as varchar) + ') ' + cast(f.food_price as varchar) Message
FROM Foods f
INNER JOIN seFoods s ON f.food_id = s.food_idThis is the output I get with the query here and the sample data in your image.Chiken (10) $5
Apple (37) $10 Peter Larsson Helsingborg, Sweden |
Edited by - SwePeso on 10/29/2006 13:09:07 |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 13:06:07
|
what is this ? how can I use that ?
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 13:09:45
|
Is that the kind of output you want?
Peter Larsson Helsingborg, Sweden |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 13:14:31
|
YEEEESSSSS exactly
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 13:17:24
|
Good. I hope you can fill in be blanks now by yourself.
I personally think (and maybe most of the clever people here) that you are heading in the wrong direction. Almost always string formatting should be done in the client-side application.
Peter Larsson Helsingborg, Sweden |
 |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 13:19:30
|
can you tell me what was the problem why we should use this type of query
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 13:20:03
|
strSQL = "SELECT f.food_name + ' (' + cast(s.quantity as varchar) + ') ' + cast(f.food_price as varchar) Message " & _
"FROM Foods f " & _
"INNER JOIN seFoods s ON f.food_id = s.food_id " & _
"WHERE s.type = 1 " & _
"ORDER BY s.qauntity DESC;"
Peter Larsson Helsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 13:26:06
|
As I wrote, you are concatenating different types of data into one string. This manipulation should almost always be handled on the client-side such as VB or ASP.
I don't think you should use this kind of query at all! I think you should useSELECT f.food_name,
s.quantity,
f.food_price
FROM Foods f
INNER JOIN seFoods s ON f.food_id = s.food_id
WHERE s.type = 1
ORDER BY s.quantity DESC and then build the wanted string in your client application (VB/ASP) as
do until rs.bof or rs.eof
sTemp = rs("food_name").value & " (" & rs("quantity").value & ") " & rs("food_price").value
''' Here I do something with the sTemp variable...
rs.MoveNext
loop
Peter Larsson Helsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
|
|
youtoo
Starting Member
22 Posts |
Posted - 10/29/2006 : 13:49:50
|
peter thanks but this gibe me thi error
Error Type: ADODB.Recordset (0x800A0CC1) Item cannot be found in the collection corresponding to the requested name or ordinal.
the item is :
strFName = rsSeFoods("food_name") intQuan = rsSeFoods("quantity")
It just works in SQL directly
and some thing new this code also works in SQL directly :
strSQL = "SELECT SeFoods.*, Foods.* From SeFoods, Foods WHERE SeFoods.food_id = Foods.food_id AND SeFoods.type = 1 "
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 10/29/2006 : 13:52:13
|
Yes of course. But you are using old ANSI syntax.
The error yup get is from that the column name you reference in the client side code, does not match the column names used in the database.
Peter Larsson Helsingborg, Sweden |
Edited by - SwePeso on 10/29/2006 13:56:11 |
 |
|
Topic  |
|