|
I have the following SQL. Tables defined.
#tbContinent ContinentID | ContinentName AddressInCountry AddressID | CountryID AddressInContinent AddressID | ContinentID NameInAddress AddressID | NameID
I then have the following SQL:
--- Insert into tbName...
Started by Gribbler on
, 4 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
JOIN ( SELECT AddressInCountry.AddressID FROM AddressInCountry UNION --ALL SELECT SELECT n.nameid AS [ID], a.addressid, n.name FROM NAMEINADDRESS t JOIN NAME n ON n.nameid AddressInContinent.AddressID FROM #tbContinent....
|
|
Table: postid|userid|post|replyto
post sql
SELECT * FROM table WHERE postid=12
total replies sql
SELECT COUNT(*) AS total FROM table WHERE replyto=12
the expected result is the "post table" + how many replies to the post. replyto field is the target postid...
Started by mozlima on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Bobby
SELECT postid, userid, post, replyto, det.nb FROM table, (SELECT COUNT....
You could use it as a SubQuery (>5.x only):
SELECT postid, userid, post, replyto, (SELECT COUNT might also work, but right now I don't see how.
|
|
I am trying to join a select disinct statement to a select sum statement. Here is an example of the data
CD STDATE ENDDATE PR F1 01/02/09 01/04/09 $10 F1 01/02/09 01/04/09 $40 F1 01/02/09 01/04/09 $20 F1 01/02/09 01/04/09 $30 F1 01/22/09 01/26/09 $10 ...
Answer Snippets (Read the full thread at stackoverflow):
SELECT CD,STDATE,ENDDATE,SUM(PR) FROM TABLE GROUP BY CD,STDATE,ENDDATE
(missed CD in original answer)
Select cd, stdate, enddate, sum(PR) from Table group by cd, stdate, enddate
I think you are looking for grouping:
select t.cd,....
|
Ask your Facebook Friends
|
I'm getting odd results from a MySQL SELECT query involving a LEFT JOIN, and I can't understand whether my understanding of LEFT JOIN is wrong or whether I'm seeing a genuinely odd behaviour.
I have a two tables with a many-to-one relationship: For every...
Started by Keith Lawrence on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
The dateid for 10-12 void this mistake in the future... .
In two of your cases, s.DateID is NULL ( LEFT JOIN ) and these are combined together BY or the result of an aggregate operation, and should not be able to be SELECT ed.
BY d.dateID.
|
|
I've had a look around on StackOverlow but haven't been able to find a definitive answer on this.
Below I have a code snippet of what I currently have, and I will explain what I am trying to achieve.
Table<Gallery> galleries = pdc.GetTable<Gallery...
Started by Robsimm on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
First3WAOrders = ( from c in customers from o in c.Orders where c.Region == "WA" select new in galleries join image in images on gallery.id equals image.galleryid into joinedimages join comment in comments on gallery.id equals comment....
|
|
There are similar questions to this, but I don't think anyone has asked this particular question.
Scenario:
Customer - Order (where Order has a CustomerID) - OrderPart - Part
I want a query that returns a customer with all its orders and each order with...
Answer Snippets (Read the full thread at stackoverflow):
If performance is really slow a....
The join if on different server) For SELECT N+1 this will obviously be longer as it will have to send the select.
A great deal of this is going to depend on the amount of data you are going through .
|
|
Hi
How would I convert the following to use INNER JOIN rather than nested SELECT?
SELECT [Name].[NameValueID], [Name].[NameTypeID], [Name].[NameID], [Name].[Value] FROM [Name] WHERE Name.NameTypeID IN ( SELECT NameTypeID FROM @tbNameType ) OR Name.NameID...
Started by Gribbler on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
INNER JOIN ( SELECT NameTypeID FROM @tbNameType ) t ON t.NameTypeID=Name.NameTypeID UNION SELECT [Name].[NameValueID], [Name].[NameTypeID], [Name].[NameID], [Name].[Value] FROM [Name] INNER JOIN ( SELECT it:
SELECT....
|
|
Hello guys, Is it possible to select only some columns from a table on a LEFT JOIN?
Started by Psyche on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Just list the columns you want to select as you would in any query:
SELECT table1.column1, table1.column2, table2.column3 FROM table1 LEFT JOIN table2 ON (...)
Note that I've included columns, you would do something like....
Of course.
|
|
Dumb question.. what logic does the database use to determine the result set if you do a select without a join such as:
select * from table1, table2
Started by Marcus on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
More info on this, applied to SQL..
It uses a cartesian product , it gives every possible combination of the two tables .
Each row in table one is matched up to each row in table two .
Cartesian product.
|
|
Hello, I am trying to make an inner join on a select statement like this:
select * from (select* from bars where rownum <= 10 )as tab1 inner join (select * from bars where rownum <= 10 )as tab2 on tab1.close=tab2.close
and I get the following error...
Answer Snippets (Read the full thread at stackoverflow):
SELECT * FROM bars b1 INNER JOIN bars....
See answers to the original question
Not quite sure why you doing that but dont forget you can alias the same table .
You don't have a space between "select" and " " in "select ".
|