473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Fetching ID's that match multiple rows.

hi...

i have the table like this,

id --------- name
--------------------
1 ---------- xxx
1 ---------- yyy
2 ---------- xxx
3 ---------- xxx
3 ---------- yyy
4 ---------- yyy
5 ---------- zzz

consider, one id is in more than one name. But,

I need the output like
id --------- name
--------------------
1 ---------- xxx
1 ---------- yyy
3 ---------- xxx
3 ---------- yyy

i will search using the field name, i give the search input is xxx and yyy.
i want the result, which are having the both values.

Thanks
S.Ashokkumar.
May 10 '07 #1
1 1626
pradeep kaltari
102 Expert 100+
hi...

i have the table like this,

id --------- name
--------------------
1 ---------- xxx
1 ---------- yyy
2 ---------- xxx
3 ---------- xxx
3 ---------- yyy
4 ---------- yyy
5 ---------- zzz

consider, one id is in more than one name. But,

I need the output like
id --------- name
--------------------
1 ---------- xxx
1 ---------- yyy
3 ---------- xxx
3 ---------- yyy

i will search using the field name, i give the search input is xxx and yyy.
i want the result, which are having the both values.

Thanks
S.Ashokkumar.
Hi,
Try the following query:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table x WHERE NAME IN ('xxx','yyy') AND x.ID IN
  2. (
  3. SELECT y.ID FROM table y 
  4. WHERE NAME IN ('xxx','yyy') AND x.NAME<>y.NAME
  5. )
  6.  
I hope this solves your problem.

Regards,
Pradeep
May 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: google | last post by:
I would like to find a way to execute a query against an MS SQL server and return a small number of rows each page load. However, I cannot read all the results in during the first page load due to...
6
by: PG | last post by:
When deleting a row from the database, that id is now missing. So what I'm trying to do is update in a loop (maybe an sql loop if there is one) of all of the id numbers - sort of like renaming...
3
by: Peter Sels | last post by:
Hello, I have a simple, but very general problem with MySQL using InnoDB tables. I am sure you experienced folks can give me a solution... Using foreign keys I want to delete a row in the...
14
by: Bobus | last post by:
Hi, I have a table which contains a bunch of prepaid PINs. What is the best way to fetch a unique pin from the table in a high-traffic environment with lots of concurrent requests? For...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
1
by: chungiemo | last post by:
Hi thought I would do another thread as this one is a bit different from the previous problem I am looking for a solution to the relating problem Comparing 2 access databases with 2 tables,...
0
by: punitshrivastava | last post by:
Hi to All Senior's, I am working in Asp.net with C#. I am newbie in C#. So i want to fetch mutiple images from database .Database i am using is Sql Server. For this i code: //get the image id...
11
donilourdu
by: donilourdu | last post by:
hi, I am trying to retrive data from MYSQL database.I am using limit to fetch the data.It will fetch two rows instead of fetching ten rows.But when i try to debug it fetches eight rows instead...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.