Help me about Select in mySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
toantt
Forum Newbie
Posts: 6
Joined: Sat May 17, 2003 11:31 pm

Help me about Select in mySQL

Post by toantt »

I want to excute select cross query in mySQL.

I have the following table:
tblTest (Id Int, Memory Varchar(50), Content Text, User Varchar(2))
Primary key(Id, Memory)

I insert some records into this table:
Insert into tblTest Values(1, 'AAA', 'Content AAA1', 'usr1'),
Values(1, 'BBB', 'Content BBB1', 'usr1'),
Values(1, 'CCC', 'Content CCC1', 'usr1')

Insert into tblTest Values(2, 'AAA', 'Content AAA2', 'usr2'),
Values(2, 'BBB', 'Content BBB2', 'usr2'),
Values(2, 'CCC', 'Content CCC2', 'usr2')
.........................


I want excute cross query that result of that query is:
Fields: Id AAA BBB CCC User
Record 1: 1 Content AAA1 Content BBB1 Content CCC1 usr1
Record 2: 2 Content AAA2 Content BBB2 Content CCC2 usr2
......... ....................................................................................


How "Select query" do I can write?
Please help me!
Thanks!
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

Do you mean a 'CROSS JOIN', from your sample I don't think that's what you mean. 'Cross Query' eh? I'm only seeing one table here.

If I understand your post, you just want to execute a SELECT query.
But, if you don't know how to do that, then what will you do once you execute it?
I would go here:
http://www.php.net/manual/en/function.mysql-query.php

Download the windows help version of the manual.
You'll love it! :wink:

- D
toantt
Forum Newbie
Posts: 6
Joined: Sat May 17, 2003 11:31 pm

Post by toantt »

I'm sory because my questions' not clearly!

I want to convert datas in rows to field column.
Ex:
In MS Access 2000, I excute cross query:


test Table:
Image

cross Query:
Image

result of cross Query:
Image

SQL String of cross query:

Code: Select all

TRANSFORM Max(tblTest.Content) AS MaxOfContent
SELECT tblTest.Id, tblTest.User
FROM tblTest
GROUP BY tblTest.Id, tblTest.User
PIVOT tblTest.Memory;
So that, i would like to write SQL in mySQL, please help me!
Post Reply