473,465 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why do I get the output of SELECT on 2 lines in mysql?

1 New Member
hi,
i wrote this code in mysql:

create table bag1 (imsi varchar(20) , bserv varchar(20) , msisdn varchar(20) , vlr varchar(20) );
create table bag3 (imsi varchar(20) , bserv varchar(20) , msisdn varchar(20) , vlr varchar(20) );
SELECT bag1.imsi , bag1.msisdn , bag1.vlr , "hlrbag1" , "MTN"
FROM bag1
where (bag1.vlr like "98935%") and (bag1.bserv="T11")
union
SELECT bag1.imsi , bag1.msisdn , bag1.vlr , "hlrbag1" , "Talia"
FROM bag1
where (bag1.vlr like "98932%") and (bag1.bserv="T11");

i need to put 2 new coulomns with the words "hlrbag1" and "MTN" next to each line outpout from SELECT, thats why i wrote "hlrbag1" , "MTN" at the end of the SELECT statement, the output i get is fine except that i get it on 2 separate lines , i need to have the output on one line. here is what i get:
imsi msisdn vlr hlrbag1 Iran_MTN
41820105 9647803 989350002
hlrbag1 MTN
41820806 96478086 9893500021
hlrbag1 Talia

i need it to be looks like this:
imsi msisdn vlr hlrbag1 MTN
41820105 9647803 989350002 hlrbag1 MTN
41820806 96478086 9893500021 hlrbag1 Talia

is it possible?
Nov 19 '10 #1
1 1612
code green
1,726 Recognized Expert Top Contributor
You haven't stated where the output is going.
But try giving the columns names
Expand|Select|Wrap|Line Numbers
  1. SELECT bag1.imsi , bag1.msisdn , bag1.vlr , "hlrbag1" AS hlr , "MTN" AS mtn
Nov 19 '10 #2

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

Similar topics

12
by: kaptain kernel | last post by:
How does one retrieve the rows in a select statement that DONT match the select. select CarIndex FROM DealerCatalog, BigCatalog WHERE DealerCatalog.CarIndex=BigCatalog.CarIndex finds all the...
3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
6
by: aa | last post by:
I use the following fragment of code to output datf from MySQL: ====================================================== $chan = mysql_connect ($db_host, $username, $password); mysql_select_db...
1
by: raglin | last post by:
I have a dynamic database that will be periodically queried to select the data from a blob field. This blob data field is text of a variable length. The data will be selected using an id field...
1
by: pizzy | last post by:
Problem: I am trying to develope my personal site to select from my mysql database and organize data on the page so that it will display all the submissions for that day, then break and display...
0
by: ZoombyWoof | last post by:
Hi. I have ran into a weird thing I just can't find any solution for. I have googled and searched but no luck. The problem is that when I select TIME values from MySQL from python, I get wrong...
9
by: cniharral | last post by:
Hi, I'm interested in printing out coloured lines of my application and I don't know what to use. Can anybody give me an idea?? Regards. Carlos Niharra López
3
uranuskid
by: uranuskid | last post by:
Hey folks, Today I'm after a solution for a pretty simple problem, however, too hard for me to solve. I've got a MySQL query that reveals a table output. But if there is no result it is displaiing...
1
by: runsun | last post by:
I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than...
6
by: Mike1961 | last post by:
Hello everyone. I have this query and this output: SELECT * , COUNT(STATE) AS strSTATE, COUNT(TYPESTATE) AS strTYPESTATE FROM tbl_MYSQL WHERE STATE = 'ABSENT'
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.