473,549 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select one row from MySQL table

11 New Member
Hi all and Merry Christmas!

I wanted to ask how would I deal with the following problem:

Say I have a table [TABLE1]:
customerid name
1 nick
2 george
3 harry

and a [TABLE2]:
number car
1 Lotus
2 BMW
2 FERRARI
2 LADA
3 Lamporgini

If I want to see george's car, I would write: SELECT car from TABLE2 where number ='2';
and I would get :
BWM
FERRARI
LADA

The thing is that I don't want to get 3 lines, but just one, where each record will be separated e.g. by TAB.
But with mysql_fetch_arr ay I will get 3 lines. I must somehow "check" for each person if he has more than one cars,
and show them in one row, not in multiple rows.

I am stuck!
Dec 30 '05 #1
3 31044
Niheel
2,456 Recognized Expert Moderator Top Contributor
Merry Christmas and Happy New Years! Only one day away from 2006.

Regrading your problem:

You can limit the results by using LIMIT.

In your case the example would look like:
SELECT car FROM table2 WHERE number='3' LIMIT 1

You can change that 1 to what ever number of results you like. Hope that helped you out. If not reply back.
Dec 30 '05 #2
SQL Maestro
1 New Member
At the moment i can't to check up - what if request is will be like this?

SELECT car FROM table2 WHERE number = '2' GROUP by number
Jan 9 '06 #3
Niheel
2,456 Recognized Expert Moderator Top Contributor
KStirig, did the solution help you answer the question? Are you trying to also group the results like:

lotus
bmw, ferrari, lada
lamborghini
Jan 9 '06 #4

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

Similar topics

5
2293
by: Alex Glaros | last post by:
I need help on my basic table connection syntaxt using PHP. I call the php from a web browser url_name_goes_here/test.php. The database name is tennis and the user name is tennis. If I type the commands directly from the MySQL> mode, my access works fine (see example 1 below). But when I try to access the table from PHP, I have a...
21
5219
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All works as expected. But >>> numb=10 >>> cursor.execute("SELECT * FROM mytest where clientID = %d",numb) Traceback (innermost last): File...
0
1364
by: Verdon vaillancourt | last post by:
Hi :) I'm not even sure if I'm naming the question correctly. I hope I can ask/explain it clearly enough to get a hint ;) Essentially... 1) I have a table of portfolio 'pieces', each row of which has a unique ID 2) I have a table of 'projects', which are comprised of a number of
0
8815
by: James Fryer | last post by:
Assuming a legal SELECT statement, this works fine: CREATE TABLE Foo SELECT ... but this does not: CREATE TABLE Foo (SELECT ...) This is a problem for me as I'd like to use the output of a SELECT...UNION...ORDER BY statement as input to CREATE TABLE.
0
3582
by: Hans Maurer | last post by:
>Description: We're running our current TTS application with MySQL (on Unix). All database, table and column names are in lower-case. However, we need to access this database with a new application which (for some reason) converts all table and column names in its SELECT statements to uppercase. Since MySQL is case-sensitive on Unix, I...
2
2405
by: skidvd | last post by:
Hello: I have just recently converted to using the InnoDB table type so that I can enforce FOREIGN key constraints. I have been using MyISAM tables (accessed via JDBC) successfully for some time. However, I have just come across a problem with the new configuration that boggles my mind.... First some configuration data:
0
1462
by: JB | last post by:
Hey ppl, I'm experiancing a very weird problem with my current Win32(win2k/XP) application. I'm using: * Delphi 7 * ADO * mySQL ODBC 3.51 drivers
4
1371
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | TicketNo | evaluation | Username ------------------------------------------------------------------------------- 1 1 ...
5
3823
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN' FOR Update; (when i execute this statement and i guess that this will lock the
17
4976
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.