SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 INNER JOIN problem , urgent help plz
 Forum Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  11:30:32  Show Profile
how can I explain, I have explained everything tell me what do you need
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  11:32:27  Show Profile  Visit SwePeso's Homepage
Then give us what we ask for!

What is the 5 with chicken and 7 with bread, meant to be?



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  11:34:38  Show Profile
that is quantity of that food
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  11:55:40  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  12:16:19  Show Profile
thanks
but again same results twice records
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  12:21:18  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  12:24:54  Show Profile
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
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  12:28:31  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  12:44:45  Show Profile
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)

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  12:55:24  Show Profile  Visit SwePeso's Homepage
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_id
This 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
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  13:06:07  Show Profile
what is this ?
how can I use that ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:09:45  Show Profile  Visit SwePeso's Homepage
Is that the kind of output you want?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  13:14:31  Show Profile
YEEEESSSSS
exactly
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:17:24  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  13:19:30  Show Profile
can you tell me what was the problem why we should use this type of query
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:20:03  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:26:06  Show Profile  Visit SwePeso's Homepage
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 use
SELECT		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
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:29:45  Show Profile  Visit SwePeso's Homepage
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

youtoo
Starting Member

22 Posts

Posted - 10/29/2006 :  13:49:50  Show Profile
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 "


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30242 Posts

Posted - 10/29/2006 :  13:52:13  Show Profile  Visit SwePeso's Homepage
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
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000