<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Need help with SQL query' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Need help with SQL query' posted on the 'Database &amp; SQL' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Tue, 18 Jun 2013 19:35:19 -0700</pubDate>
    <lastBuildDate>Tue, 18 Jun 2013 19:35:19 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Need help with SQL query</title>
      <link>http://www.programmersheaven.com/mb/database/423980/423980/need-help-with-sql-query/</link>
      <description>I am very new to SQL and not a programmer by trade.  I know enough to be dangerous.  I need a query (I'm using Toad for SQL) that extracts information when multiple conditions from the same table are met ... essentially pull data when it equals this AND equals this.  Example:&lt;br /&gt;
&lt;br /&gt;
Last	First	Order#	Item&lt;br /&gt;
Doe	John	1111	Candy&lt;br /&gt;
Doe	John	1111	Gum&lt;br /&gt;
Doe	John	1111	Chips&lt;br /&gt;
Doe	John	2222	Candy&lt;br /&gt;
Doe	John	2222	Chips&lt;br /&gt;
Smith	Jane	3333	Candy&lt;br /&gt;
Smith	Jane	4444	Candy&lt;br /&gt;
Smith	Jane	4444	Chips&lt;br /&gt;
Smith	Jane	5555	Gum&lt;br /&gt;
&lt;br /&gt;
Right now, my select statement is "Select Last, First, Order # when Item in ('Candy', 'Gum')".  I'm getting six returns since it is matching entries with either "Candy" or either "Gum".  However, I need a statement that pulls a value when both 'Candy' and 'Gum' are purchased by the same customer in the same order #.  Given the data above, I only want "Doe, John, 1111" returned.  Can anyone help?  And just for the record, this is not a homework assignment ... &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/database/423980/423980/need-help-with-sql-query/</guid>
      <pubDate>Mon, 06 Jun 2011 12:22:39 -0700</pubDate>
      <category>Database &amp; SQL</category>
    </item>
    <item>
      <title>Re: Need help with SQL query</title>
      <link>http://www.programmersheaven.com/mb/database/423980/424414/re-need-help-with-sql-query/#424414</link>
      <description>you could try this syntax to pull your data,&lt;br /&gt;
SELECT DISTINCT Last, First, Order# FROM your table WHERE Item = 'Candy' OR 'Gum';&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/database/423980/424414/re-need-help-with-sql-query/#424414</guid>
      <pubDate>Fri, 29 Jul 2011 00:49:49 -0700</pubDate>
      <category>Database &amp; SQL</category>
    </item>
    <item>
      <title>Re: Need help with SQL query</title>
      <link>http://www.programmersheaven.com/mb/database/423980/427802/re-need-help-with-sql-query/#427802</link>
      <description>Here is the SQL statement you should use. Enjoy.&lt;br /&gt;
&lt;br /&gt;
Select t1.Last, t1.First, t1.Order from table t1, table t2 where t2.Order = t1.Order and t1.Item = 'Candy' and t2.Item = 'Gum';&lt;br /&gt;
&lt;a href="http://www.magellan.cc"&gt;Web Directory&lt;/a&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/database/423980/427802/re-need-help-with-sql-query/#427802</guid>
      <pubDate>Thu, 08 Mar 2012 14:24:27 -0700</pubDate>
      <category>Database &amp; SQL</category>
    </item>
  </channel>
</rss>