<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ä¸­å›½ç½‘ç»œ(86SQL.COM)ä¼ä¸šé‚®ä»¶ç³»ç»Ÿ &#187; subquery</title>
	<atom:link href="http://subeijihua.org/category/subquery/feed" rel="self" type="application/rss+xml" />
	<link>http://subeijihua.org</link>
	<description></description>
	<lastBuildDate>Fri, 16 Apr 2010 22:31:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to calculate the difference of the same field in two rows in Microsoft Access?</title>
		<link>http://subeijihua.org/subquery/how-to-calculate-the-difference-of-the-same-field-in-two-rows-in-microsoft-access</link>
		<comments>http://subeijihua.org/subquery/how-to-calculate-the-difference-of-the-same-field-in-two-rows-in-microsoft-access#comments</comments>
		<pubDate>Sat, 13 Feb 2010 00:16:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/how-to-calculate-the-difference-of-the-same-field-in-two-rows-in-microsoft-access</guid>
		<description><![CDATA[I have a table that has clock in time in one row and clock out time in another row. I need to be able to sum the hours worked in a day.
TIMESTAMP ETEMP# ETIORO PMNAME
1/2/09 8:56 AM 213 I John Deere
1/2/09 1:15 PM 213 O John Deere
1/2/09 1:43 PM 213 I John Deere
1/2/09 6:03 PM [...]]]></description>
			<content:encoded><![CDATA[<p>I have a table that has clock in time in one row and clock out time in another row. I need to be able to sum the hours worked in a day.</p>
<p>TIMESTAMP ETEMP# ETIORO PMNAME<br />
1/2/09 8:56 AM 213 I John Deere<br />
1/2/09 1:15 PM 213 O John Deere<br />
1/2/09 1:43 PM 213 I John Deere<br />
1/2/09 6:03 PM 213 O John Deere</p>
<p>I created two queries in access, one with clock in data and one with cloc out data and added the field DateVal for the day. I then created a query with the following SQL language.</p>
<p>SELECT ClockIn.DateVal, ClockIn.[ETEMP#], ClockIn.PMNAME, ClockIn.ETIORO, ClockOut.ETIORO, ClockIn.TIMESTAMP, ClockOut.TIMESTAMP, DateDiff(&quot;n&quot;,[clockin].[timestamp],[clockout].[timestamp])/60 AS [Hours]</p>
<p>FROM ClockIn INNER JOIN ClockOut ON (ClockIn.[ETEMP#]=ClockOut.[ETEMP#]) AND (ClockIn.DateVal=ClockOut.DateVal)</p>
<p>WHERE (((ClockIn.DateVal)=#1/2/2009#) And ((ClockIn.PMNAME)=&quot;John Deere&quot;));</p>
<p>This is the result I get:</p>
<p>DateVal ETEMP# PMNAME ClockIn.ETIORO ClockOut.ETIORO ClockIn.TIMESTAMP ClockOut.TIMESTAMP Hours<br />
1/2/09 213 John Deere I O 1/2/09 1:43 PM 1/2/09 1:15 PM -0.466666667<br />
1/2/09 213 John Deere I O 1/2/09 8:56 AM 1/2/09 1:15 PM 4.316666667<br />
1/2/09 213 John Deere I O 1/2/09 1:43 PM 1/2/09 6:03 PM 4.333333333<br />
1/2/09 213 John Deere I O 1/2/09 8:56 AM 1/2/09 6:03 PM 9.116666667</p>
<p>How do I eliminate the duplication and get true hours worked for the day. I think it can be done with a subquery, but that is out of my league. Any help is greatly appreciated.<br />
<br />I don&#8217;t know access syntex, but I can give you my 2 cents how to achive this using one simple query using aggregation.</p>
<p>convert your timestamp to minutes (timestamp &#8211; the date), then 8:56 will be 8&#215;60 + 56 = 536, 1:15 =&gt; 795<br />
1:43 =&gt;823, 6:03=&gt;1083. If Access can handle case statement, that will be great, if not, add a column called &quot;sign&quot;, -1 for clock in, 1 for clock out.</p>
<p>select Sum (theCovertedMinutes * sign)<br />
from your table<br />
group by PMName</p>
<p>You will get -536+795-823+1083 = 519 minute</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/how-to-calculate-the-difference-of-the-same-field-in-two-rows-in-microsoft-access/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>how do you create a subquery in access?</title>
		<link>http://subeijihua.org/subquery/how-do-you-create-a-subquery-in-access</link>
		<comments>http://subeijihua.org/subquery/how-do-you-create-a-subquery-in-access#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:41:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/how-do-you-create-a-subquery-in-access</guid>
		<description><![CDATA[what would you do/type?
select
from employees;
the easy way to get into that is to build 2 queries and use the query designer instead of trying to write sql code first.
so, let&#8217;s say you have an &#8216;employees&#8217; table and a table that tracks absences and they&#8217;re keyed on an employee id field
in you primary query from the [...]]]></description>
			<content:encoded><![CDATA[<p>what would you do/type?</p>
<p>select<br />
from employees;<br />
<br />the easy way to get into that is to build 2 queries and use the query designer instead of trying to write sql code first.</p>
<p>so, let&#8217;s say you have an &#8216;employees&#8217; table and a table that tracks absences and they&#8217;re keyed on an employee id field</p>
<p>in you primary query from the employee table, you want:<br />
emplid   empl name and then you want the 3rd data item to be their number of days absent</p>
<p>create a separate totals query that counts the number of days absent, grouped by Emp id.  they view that query in sql mode and copy/paste it in your main query in the 2rd column (some editing is required to remove the &#8216;;&#8217; at the end and other changes depending on your tables)</p>
<p>so now, for every record in your main query, it will run the sub query and display the empid, name, and # days absent.</p>
<p>NOTE: before everyone jumps on it there are much easier way to accomplish this result but it&#8217;s a good basic subquery example.</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/how-do-you-create-a-subquery-in-access/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hi, does any1 have Oracle answers to these q&#8217;s? Thanks!?</title>
		<link>http://subeijihua.org/subquery/hi-does-any1-have-oracle-answers-to-these-qs-thanks</link>
		<comments>http://subeijihua.org/subquery/hi-does-any1-have-oracle-answers-to-these-qs-thanks#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:13:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/hi-does-any1-have-oracle-answers-to-these-qs-thanks</guid>
		<description><![CDATA[12.Using a WITH clause write a SELECT statement to list the job_title of those jobs whose maximum salary is more than half the maximum salary of the entire company. Name your subquery MAX_CALC_SAL. Name the columns in the result JOB_TITLE and JOB_TOTAL, and sort the result on JOB_TOTAL in descending order. Hint: Examine the jobs [...]]]></description>
			<content:encoded><![CDATA[<p>12.Using a WITH clause write a SELECT statement to list the job_title of those jobs whose maximum salary is more than half the maximum salary of the entire company. Name your subquery MAX_CALC_SAL. Name the columns in the result JOB_TITLE and JOB_TOTAL, and sort the result on JOB_TOTAL in descending order. Hint: Examine the jobs table. You will need to join JOBS and EMPLOYEES to display the job_title.</p>
<p>13.Write one query to return the employee_id, job_id, hire_date and department_id of all employees and a second query listing employee_id, job_id, start_date and department_id from the job_hist table and combine the results as one single output. Make sure you suppress duplicates in the output.</p>
<p>14.DJs on Demand just purchased four new CDs. Use an explicit INSERT statement to add each CD to the copy_d_cds table. After completing the entries, execute a SELECT * statement to verify your work. </p>
<p>CD_NUMBERTITLEPRODUCERYEAR<br />
97Celebrate the DayR&amp;B Inc.2003</p>
<p>98Holiday Tunes for All AgesTunes are Us<br />
2004<br />
99Party MusicOld Town Records2004<br />
100Best of Rock and RollOld Town Records2004</p>
<p>15.DJs on Demand has two new events coming up. One event is a fall football party and the other event is a sixties theme party. The DJs on Demand clients requested the songs shown in the table for their events. Add these songs to the copy_d_songs table using an implicit INSERT statement. </p>
<p>IDTITLEDURATIONTYPE_CODE<br />
52Surfing Summer Not known12</p>
<p>53Victory Victory5 MINS<br />
12</p>
<p>16.Monique Tuttle, the manager of Global Fast Foods, sent a memo requesting an immediate change in prices. The price for a strawberry shake will be raised from $3.59 to $3.75, and the price for fries will increase to $1.20. Make these changes to the copy_f_food_items table. </p>
<p>17.Add the new customers shown below to the copy_f_customers table. You may already have added Katie Hernandez. Will you be able to add all these records successfully? </p>
<p>ID FIRST_<br />
NAME LAST_<br />
NAME ADDRESS CITY STATE ZIP PHONE_NUMBER<br />
145 Katie Hernandez 92 Chico Way Los Angeles CA 98008 8586667641<br />
225 Daniel Spode 1923 Silverado Denver CO 80219 7193343523<br />
230 230 Adam Zurn 5 Admiral Way Seattle WA 4258879009 </p>
<p>18.Sue Doe has been an outstanding Global Foods staff member and has been given a salary raise. She will now be paid the same as Bob Miller. Update her record in copy_f_staffs. </p>
<p>19.When would you want a DEFAULT value?</p>
<p>20.Complete the GRADUATE CANDIDATE table instance chart. Credits is a foreign key column referencing the requirements table.</p>
<p>21.Write the syntax to create the grad_candidates table. Confirm creation of the table using DESCRIBE.</p>
<p>Column<br />
Name<br />
student_idlast_namefirst_namecreditsgraduation_date</p>
<p>Key Type</p>
<p>Nulls/Unique</p>
<p>FK Column</p>
<p>DatatypeNUMBERVARCHAR2VARCHAR2NUMBERDATE</p>
<p>Length63</p>
<p>22.In your o_employees table, enter a new column called “Termination.” The datatype for the new column should be VARCHAR2. Set the DEFAULT for this column as SYSDATE to appear as character data in the format: February 20th, 2003.</p>
<p>23.Create a new column in the o_employees table called start_date. Use the TIMESTAMP WITH LOCAL TIME ZONE as the datatype. </p>
<p>24.Using the column information for the animals table below, name constraints where applicable at the table level, otherwise name them at the column level. Define the primary key (animal_id). The license_tag_number must be unique. The admit_date and vaccination_date columns cannot contain null values.<br />
animal_id NUMBER(6)<br />
name VARCHAR2(25)<br />
license_tag_number NUMBER(10)<br />
admit_date DATE<br />
adoption_id NUMBER(5),<br />
vaccination_date DATE</p>
<p>25.Create the animals table. Write the syntax you will use to create the table.<br />
<br />the answer is 2</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/hi-does-any1-have-oracle-answers-to-these-qs-thanks/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS Access Help?</title>
		<link>http://subeijihua.org/subquery/ms-access-help</link>
		<comments>http://subeijihua.org/subquery/ms-access-help#comments</comments>
		<pubDate>Sun, 06 Dec 2009 17:13:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/ms-access-help</guid>
		<description><![CDATA[I have a form that includes numerous Bonus codes. I labelled the fields as BC1, BC2, BC3&#8230;&#8230;BC12. ( in the table)
The bonus code is a number and it varies  from 100 to 114. After having numerous records, I now want to do a query that will give me all my bonus code entries ( [...]]]></description>
			<content:encoded><![CDATA[<p>I have a form that includes numerous Bonus codes. I labelled the fields as BC1, BC2, BC3&#8230;&#8230;BC12. ( in the table)</p>
<p>The bonus code is a number and it varies  from 100 to 114. After having numerous records, I now want to do a query that will give me all my bonus code entries ( all 12 fields) in ascending order. For example I dont want</p>
<p>100<br />
111<br />
112</p>
<p>100<br />
113<br />
114</p>
<p> I want </p>
<p>100, 100, 111, 112, 113, 114. </p>
<p>Any idea how I can overcome this?? Im think ill have to do a subquery&#8230;but im not sure.<br />
<br />SELECT blah<br />
FROM blah<br />
WHERE blah<br />
SORT BY ascending &lt;- this does the trick</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/ms-access-help/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Database / SQL question &#8211; this is hard?</title>
		<link>http://subeijihua.org/subquery/database-sql-question-this-is-hard</link>
		<comments>http://subeijihua.org/subquery/database-sql-question-this-is-hard#comments</comments>
		<pubDate>Fri, 04 Dec 2009 03:02:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/database-sql-question-this-is-hard</guid>
		<description><![CDATA[I have two tables that use either three or four logical keys to determine duplication.  I need to populate the 3-key table with the 4-key&#8217;s unique field.  The keys map like this
3-Key
ABC
4-Key
ABCD
I need to get D, put it into 3-key, when there&#8217;s a match based on ABC.  Here&#8217;s the catch.  ABC [...]]]></description>
			<content:encoded><![CDATA[<p>I have two tables that use either three or four logical keys to determine duplication.  I need to populate the 3-key table with the 4-key&#8217;s unique field.  The keys map like this</p>
<p>3-Key<br />
ABC</p>
<p>4-Key<br />
ABCD</p>
<p>I need to get D, put it into 3-key, when there&#8217;s a match based on ABC.  Here&#8217;s the catch.  ABC are allowed to be equal on both tables, and D is the only real designator or uniqueness on the 4-key.  Examples:</p>
<p>4-Key<br />
A                B    C         D<br />
ALGEBRA    12349999  X7<br />
ALGEBRA    12349999 A2<br />
ALGEBRA    12349999 P6<br />
ALGEBRA    12349996 F8<br />
ALGEBRA    12349199 K1<br />
ALGEBRA    12349299 E2<br />
ALGEBRA    12349013 C9<br />
ALGEBRA    12349988          Z5</p>
<p>3 Key<br />
A                B    C<br />
ALGEBRA    12349999<br />
ALGEBRA    12349999<br />
ALGEBRA    12349999<br />
ALGEBRA    12349996<br />
ALGEBRA    12349199<br />
ALGEBRA    12349299<br />
ALGEBRA    12349013<br />
ALGEBRA    12349988       </p>
<p>The problem &#8211; when I try joining the two tables I get the &quot;ORA-01427: single-row subquery returns more than one row&quot; because it doesn&#8217;t know how to handle the first three rows in 3-Key (which D do I take?)</p>
<p>How can I make it so that it fills in all the rows after the first three, in other words, fill in when the query returns one row, and do nothing but don&#8217;t fail if it returns more than one?</p>
<p>My code:<br />
update grade_table b<br />
set b.D =<br />
(select distinct<br />
a.D from local_college_course a<br />
where<br />
trim(b.A||b.B||b.C)=trim(a.A||a.B||a.C)<br />
and a.D is not null<br />
group by a.D<br />
having count(distinct a.D) = 1<br />
)<br />
where exists (select &#8216;x&#8217; from local_college_course a<br />
where<br />
trim(b.A||b.B||b.C)=trim(a.A||a.B||a.C)<br />
and a.D is not null)</p>
<p>I replaced the actual column names with ABCD to save space.  I need it to look like this</p>
<p>3-Key<br />
A                B    C      D<br />
ALGEBRA    12349999<br />
ALGEBRA    12349999<br />
ALGEBRA    12349999<br />
ALGEBRA    12349996  F8<br />
ALGEBRA    12349199  K1<br />
ALGEBRA    12349299  E2<br />
ALGEBRA    12349013  C9<br />
ALGEBRA    12349988  Z5</p>
<p>I can&#8217;t just dedupe the 4-key table because there are lot of fields I need to maintain on it.<br />
tried your suggestion.  Its not identifying the columns in the second subquery &#8211; </p>
<p>select * from local_college_course l, ( &lt;insert Query 1&gt; ) k<br />
where k.A=l.A and k.B=l.B and k.C=l.C</p>
<p>ERROR at line 5:<br />
ORA-00904: &quot;L&quot;.&quot;C&quot;: invalid identifier<br />
both excellent answers, but I&#8217;m having better luck with techieguys.  I&#8217;m reduced to this error: </p>
<p>ORA-00904: &quot;T1&quot;.&quot;C&quot;: invalid identifier</p>
<p>its in ref to line 15: WHERE t.a = t1.a AND t.b = t1.b AND t.c = t1.c)</p>
<p>any thoughts on what I&#8217;m doing wrong?<br />
<br />Oy gevalt!</p>
<p>Ok, you can do this with multiple subqueries:</p>
<p>First you&#8217;d trim 4 Key to the lines with one D value per unique ABC:<br />
(I&#8217;m not checkign syntax on this stuff):<br />
Query1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
select A, B,C , count (*)<br />
from  local_college_course<br />
group by A,B,C<br />
having count (*) =1 </p>
<p>You actually have &#8216;distinct D&#8217; in your &#8216;having&#8217;. Who designed this table and why do they hate you?</p>
<p>Next you&#8217;d rejoin that with original local_college_course:</p>
<p>Query 2<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
select * from local_college_course l, ( &lt;insert Query 1&gt; ) k<br />
where k.A=l.A and k.B=l.B and k.C=l.C</p>
<p>and then use THAT to join with grade_table:</p>
<p>update grade_table b<br />
set b.D= ( select D from ( &lt;insert QUERY 2&gt; ) where trim ( yadda yadda yadda &#8230;.</p>
<p>You get the idea.</p>
<p>Good luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/database-sql-question-this-is-hard/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SQL: Cant link sub-queries?</title>
		<link>http://subeijihua.org/subquery/sql-cant-link-sub-queries</link>
		<comments>http://subeijihua.org/subquery/sql-cant-link-sub-queries#comments</comments>
		<pubDate>Sun, 29 Nov 2009 08:51:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/sql-cant-link-sub-queries</guid>
		<description><![CDATA[Im supposed to list the names of actors who have stared in more than 3 films
This is wrong but its all i can think of and everything needed should be there.
SELECT fname, surname
FROM actor
WHERE a_id=(SELECT actor_id FROM acts WHERE movie_id=(SELECT Count(*) FROM acts GROUP BY actor_id HAVING (COUNT(*)&#62;3)));
Its wrong in the first subquery but i [...]]]></description>
			<content:encoded><![CDATA[<p>Im supposed to list the names of actors who have stared in more than 3 films</p>
<p>This is wrong but its all i can think of and everything needed should be there.</p>
<p>SELECT fname, surname<br />
FROM actor<br />
WHERE a_id=(SELECT actor_id FROM acts WHERE movie_id=(SELECT Count(*) FROM acts GROUP BY actor_id HAVING (COUNT(*)&gt;3)));</p>
<p>Its wrong in the first subquery but i dont know what to do?<br />
SELECT fname, surname<br />
FROM actor<br />
WHERE a_id=(SELECT actor_id FROM acts GROUP BY actor_id HAVING (COUNT(*)&gt;3));</p>
<p>This is better but wont work because the sub querie returns 2 answers and it only allows 1 for sub queries?<br />
<br />SELECT fname, surname<br />
FROM actor<br />
WHERE a_id IN (SELECT actor_id FROM acts GROUP BY actor_id HAVING (COUNT(*)&gt;3));</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/sql-cant-link-sub-queries/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I need some help writing a sql query?</title>
		<link>http://subeijihua.org/subquery/i-need-some-help-writing-a-sql-query</link>
		<comments>http://subeijihua.org/subquery/i-need-some-help-writing-a-sql-query#comments</comments>
		<pubDate>Tue, 17 Nov 2009 10:47:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/i-need-some-help-writing-a-sql-query</guid>
		<description><![CDATA[I am wanting to figure out how to write a query that will select specific rows from different tables, which shouldnt be a problem, i will just use the related keys to relate the tables. there is one table that I need to do something different with. In this table, the key will relate to [...]]]></description>
			<content:encoded><![CDATA[<p>I am wanting to figure out how to write a query that will select specific rows from different tables, which shouldnt be a problem, i will just use the related keys to relate the tables. there is one table that I need to do something different with. In this table, the key will relate to another table fine, but then there is another field that has a number value and each of these number values mean different things. for instance, The key in this table may be the number &quot;5&quot;. There could be 20 values for &quot;5&quot; with the value in one of the rows different in each, which that is the row that tells me what the record is for. more specifically, lets say there is a table called claimant and the table in question is called Sub_Data. They will be related by the key claimant_id. WHen they are related, the Sub_Data table has a field called value and a field called ID. The ID field is a number that can be translated to tell me what the generic field value is a value for. I want to do a select where I can get all of the claimant values, with the Sub_Data.Value field when it is a certain value only. This is what I have gotten, but it doesnt work, and i know why it doesnt work, just putting it down to give people an idea&#8230;.</p>
<p>select *, (select value from Sub_Data, claimant where Sub_Data.claimant_id = Claimant.claimant_id and Sub_Data.id = &#8216;72&#8242;) as B from Claimant</p>
<p>The above returns multiple rows on the subquery which obviously wont work,<br />
Any ideas? this was kind of hard to explain so it may be confusing&#8230;</p>
<p>Thnks Keg, I will try that tomorrow and see if that is what I am looking for<br />
ok, same question but I need to add something, what if I want to also get the result where the id is say &#8216;22&#8242;, &#8216;72&#8242;, and &#8216;600&#8242; for each claimant id; how would I get a select statement where it returns all the results for claimant along with columns of the result of value with the above 3 ids from the sub_data table?<br />
<br />You can do this by referencing the sub_data table under 3 aliases.</p>
<p>select<br />
     c.*,<br />
     s72.value  as value_72,<br />
     s22.value as value_22,<br />
     s600.value as value_600<br />
from<br />
      claimant c<br />
      left outer join sub_data s72<br />
            on c.claimant_id = s72.claimant_id and<br />
                 s72.id = &#8216;72&#8242;<br />
      left outer join sub_data s22<br />
            on c.claimant_id = s22.claimant_id and<br />
                 s22.id = &#8216;22&#8242;<br />
      left outer join sub_data s600<br />
            on c.claimant_id = s600.claimant_id and<br />
                 s600.id = &#8216;600&#8242;</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/i-need-some-help-writing-a-sql-query/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How do I insert multiple rows in  MySQL using nested select  statements?</title>
		<link>http://subeijihua.org/subquery/how-do-i-insert-multiple-rows-in-mysql-using-nested-select-statements</link>
		<comments>http://subeijihua.org/subquery/how-do-i-insert-multiple-rows-in-mysql-using-nested-select-statements#comments</comments>
		<pubDate>Sat, 14 Nov 2009 06:18:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/how-do-i-insert-multiple-rows-in-mysql-using-nested-select-statements</guid>
		<description><![CDATA[e.g. insert into lmms.household (id,family_name,location_id,last_update_time,last_update_user_id,creation_time,creation_user_id) values
((select households_id from world.households),(select family_name from world.households),&#34;93469603&#34;,(select last_updated from world.households),&#34;1&#34;,(select created_date from world.households),&#34;1&#34;);
returns an error- &#34;subquery returns more than one row&#34;?
How can this statement be re-written?
select households_id from world.households
select family_name from world.households
select last_updated from world.households
those statements need to be 1 row.
just put a conditional like where whatever = whatever
]]></description>
			<content:encoded><![CDATA[<p>e.g. insert into lmms.household (id,family_name,location_id,last_update_time,last_update_user_id,creation_time,creation_user_id) values<br />
((select households_id from world.households),(select family_name from world.households),&quot;93469603&quot;,(select last_updated from world.households),&quot;1&quot;,(select created_date from world.households),&quot;1&quot;);<br />
returns an error- &quot;subquery returns more than one row&quot;?<br />
How can this statement be re-written?<br />
<br />select households_id from world.households<br />
select family_name from world.households<br />
select last_updated from world.households</p>
<p>those statements need to be 1 row.<br />
just put a conditional like where whatever = whatever</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/how-do-i-insert-multiple-rows-in-mysql-using-nested-select-statements/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to display counted value of database column using count function in php?</title>
		<link>http://subeijihua.org/subquery/how-to-display-counted-value-of-database-column-using-count-function-in-php</link>
		<comments>http://subeijihua.org/subquery/how-to-display-counted-value-of-database-column-using-count-function-in-php#comments</comments>
		<pubDate>Wed, 11 Nov 2009 11:59:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/how-to-display-counted-value-of-database-column-using-count-function-in-php</guid>
		<description><![CDATA[I have two tables (newassignment,bugstatus) I have made one query i.e
$query = &#34;select assign_name,credit,(select count(bug_id) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=&#8217;Approved&#8217;),(select count(bug_status) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=&#8217;Pending&#8217;) from newassignment where client_userid=2&#34;;
this query is executed in mysql but I don&#8217;t understand how to display this [...]]]></description>
			<content:encoded><![CDATA[<p>I have two tables (newassignment,bugstatus) I have made one query i.e<br />
$query = &quot;select assign_name,credit,(select count(bug_id) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=&#8217;Approved&#8217;),(select count(bug_status) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=&#8217;Pending&#8217;) from newassignment where client_userid=2&quot;;</p>
<p>this query is executed in mysql but I don&#8217;t understand how to display this sql output in php page. I am able to display first value i.e assign_name,credit value but can&#8217;t display counted value which is given subquery.<br />
<br />UPDATE: Seems I misread your question.</p>
<p>What you need to do is set a &quot;column name&quot; for the computed value, for example:</p>
<p>SELECT count(ColumnID) AS RowCount FROM TableName</p>
<p>The &quot;AS RowCount &quot; is the key to giving it a column name, this way you will be able to reference it much easier with in PHP, just like your other columns.</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/how-to-display-counted-value-of-database-column-using-count-function-in-php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Subqueries in MySQL 4.1?</title>
		<link>http://subeijihua.org/subquery/subqueries-in-mysql-4-1</link>
		<comments>http://subeijihua.org/subquery/subqueries-in-mysql-4-1#comments</comments>
		<pubDate>Sun, 08 Nov 2009 16:17:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[subquery]]></category>

		<guid isPermaLink="false">http://subeijihua.org/subquery/subqueries-in-mysql-4-1</guid>
		<description><![CDATA[If I do a query for:
select id from table1 where user=&#34;me&#34;
I get a list of 5 items.
Now I want to exclude those 5 ids from another query, with something like this:
select content from sentences where id NOT IN ( (select id from table1 where user=&#34;me&#34;) )
But that gives me an error of &#34;Subquery returns more [...]]]></description>
			<content:encoded><![CDATA[<p>If I do a query for:<br />
select id from table1 where user=&quot;me&quot;</p>
<p>I get a list of 5 items.</p>
<p>Now I want to exclude those 5 ids from another query, with something like this:</p>
<p>select content from sentences where id NOT IN ( (select id from table1 where user=&quot;me&quot;) )</p>
<p>But that gives me an error of &quot;Subquery returns more than 1 row&quot;.  Anyone have any suggestions to make this work?<br />
<br />u cannot use sub queries in mysql 4.1</p>
<p>u need to hava 5.0</p>
]]></content:encoded>
			<wfw:commentRss>http://subeijihua.org/subquery/subqueries-in-mysql-4-1/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

