Simple SQL question!


 
Thread Tools Search this Thread
Top Forums Programming Simple SQL question!
# 1  
Old 05-11-2009
Simple SQL question!

Hi all,

I would like to display more values of different tables in one row. The issue is that I want to display more values from the same column!

exp.

Table1

id | col1
----------
1 val1
2 val2

Table2

id | col2
-----------
1 val2
2 val3
3 val4


My goal:

Table1.id-A Table1.col1-A Table1.id-B Table1.col1-B Table2.id-A Table2.col-A ......

1 val1 2 val2 1 val1 2 val2 3 val3 ........

Any idea? Thanks in advance!
# 2  
Old 05-11-2009
Quote:
Originally Posted by research3
... 3 val3 ........
Where did the (id, column) pair of (3, val3) come from ? It isn't there either in Table1 or Table2.

Quote:
...
1 val1 2 val2 1 val1 2 val2 ...
The tuples (1, val1) and (2, val2) are in Table1. Do you want them repeated like you've shown above ?

Quote:
...

Table1

id | col1
----------
1 val1
2 val2

Table2

id | col2
-----------
1 val2
2 val3
3 val4

My goal:

Table1.id-A Table1.col1-A Table1.id-B Table1.col1-B Table2.id-A Table2.col-A ......
I don't see "id-A", "id-B", "col1-A", "col1-B" anywhere in the sample data you provided.

Which database ? What database version ?


tyler_durden
# 3  
Old 05-11-2009
No I don't want to repeate the entries, I just want to show all enties in one row(line).

I mean the diffenet values in one column wit the char: (-A, -B ...) "But the columns names is not important from my point of view!

The Mysql version is 5.0
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Oracle simple SQL query result in: ORA-08103: object no longer exists

Dear community, please help with a query on Oracle. I'm using SQLPlus (but with SQLDeveloper is the same) to accamplish a sinple query like: select count(*) from ARCHIT_D_TB where (TYP_ID=22 OR TYP_ID=23) and SUB_TM like '%SEP%' and CONS=1234This is a very simple query that works perfect until... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

2. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

3. UNIX for Dummies Questions & Answers

Simple Question

Hi Guys, I've been learning UNIX for the past couple of days and I came across this exercise, I can't get my head around it, so I would be ever so grateful if I could receive some sort of help or direction with this. Create a file with x amount of lines in it, the content of your choice. ... (3 Replies)
Discussion started by: aforball
3 Replies

4. Shell Programming and Scripting

Sorry question on SQL

Experts, I need small help in oracle. I am just putting this question here because i think there are SQL geniuses here as well as UNIX. I have a string that contains the First name, Middle name and last name in one field in the table in Oracle. I need to extract each one of them... (5 Replies)
Discussion started by: dsravan
5 Replies

5. Programming

Simple C question... Hopefully it's simple

Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple... (6 Replies)
Discussion started by: Xeed
6 Replies

6. UNIX for Dummies Questions & Answers

simple if then fi question

i'm trying to make a script that prints the name of the script for any command line parameter, here is what i have, and get `]]' unexpected: what am i doing wrong? (3 Replies)
Discussion started by: tefflox
3 Replies

7. Shell Programming and Scripting

Simple question.

Is it possible to establish an IF statement inside a case statement in a shell file ? thx (2 Replies)
Discussion started by: TARFU
2 Replies

8. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

9. UNIX for Dummies Questions & Answers

Simple Question

Can anyone tell me if there is a way to remove the encryption from Data CDs by UNIX? Or does anyone know of a program that can remove the encryption? I would much appreciate it! Thanks, -Peaves (2 Replies)
Discussion started by: Peaves
2 Replies

10. UNIX for Dummies Questions & Answers

Simple question?

I've been a Linux user for quite some time, started out with Red Hat and Mandrake, and just recently moved to Slackware linux.... my question is this: Is there a big difference between Linux and Unix? If so, what? I was just looking at Sun's Solaris 8 thats free for download on Intel... (5 Replies)
Discussion started by: Cuthbert
5 Replies
Login or Register to Ask a Question