vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hey NG, I got a tabel like this: +----+-------+--------+ | id | value | type | +----+-------+--------+ | 1 | 512 | art no | +----+-------+--------+ | 2 | 32 | size | +----+-------+--------+ And i would like to get a result like this: +--------+--------+ | art_no | size | +--------+--------+ | 512 | 32 | +--------+--------+ I can't do subselections, like i can in MS SQL - can anyone solve my problem? Kind regards, Kasper K. |
| |||
| Kasper K wrote: > | id | value | type | > +----+-------+--------+ > | 1 | 512 | art no | > | 2 | 32 | size | > And i would like to get a result like this: > | art_no | size | > +--------+--------+ > | 512 | 32 | > I can't do subselections, like i can in MS SQL - can anyone solve my > problem? Write how you would do that in T-SQL. Maybe that will help someone get a better idea of what you want. |
| |||
| Walter Vaughan skrev: > Write how you would do that in T-SQL. Maybe that will help someone get a > better idea of what you want. Hey Walter, T-SQL? im not familiar with that? The thing i want though is - if you take a look at my first table you see that i have a col named: value, and another col named: type. Now i want to split my value col out in one row. And let the new tabel field titels become my type col text. Is it still hard to understand? I explain the best i can - and i really need your help! Im using MySQL 4.1 Kind regards, Kasper K. |
| |||
| Kasper K wrote: > T-SQL? im not familiar with that? T-SQL is Microsoft's version of SQL. If you would write what you want in Microsoft's version of SQL, someone here might be able to come up with a work around for MySQL. -- Walter |
| |||
| Walter Vaughan skrev: > T-SQL is Microsoft's version of SQL. If you would write what you want in > Microsoft's version of SQL, someone here might be able to come up with a > work around for MySQL. It wouyld be something like this: persons : ID, NAME weddings: ID, MANID, WOMANID, DATE SELECT DATE, (SELECT NAME FROM PERSONS WHERE persons.ID=wedding.MANID) AS MANNAME, (SELECT NAME FROM PERSONS WHERE persons.ID=wedding.WOMANID) AS WOMANNAME FROM WEDDINGS Result: DATE MANNAME WOMANNAME 2000-01-01 John Mary 2000-01-05 Johnny Betty A query where i can make more than one select and where statement.. I hope you are able to help me. |
| |||
| Kasper K wrote: > Walter Vaughan skrev: >> T-SQL is Microsoft's version of SQL. If you would write what you >> want in Microsoft's version of SQL, someone here might be able to >> come up with a work around for MySQL. > > It wouyld be something like this: > > persons : ID, NAME > weddings: ID, MANID, WOMANID, DATE > > SELECT DATE, > (SELECT NAME FROM PERSONS WHERE persons.ID=wedding.MANID) AS MANNAME, > (SELECT NAME FROM PERSONS WHERE persons.ID=wedding.WOMANID) AS > WOMANNAME FROM WEDDINGS > > Result: > > DATE MANNAME WOMANNAME > 2000-01-01 John Mary > 2000-01-05 Johnny Betty > > > A query where i can make more than one select and where statement.. > I hope you are able to help me. SELECT weddings.Date, persons1.Name AS manname, persons2.name AS womanname FROM `weddings` JOIN persons AS persons1 ON weddings.manid = persons1.id JOIN persons AS persons2 ON weddings.womanid = persons2.id |
| ||||
| Paul Lautman skrev: > SELECT weddings.Date, persons1.Name AS manname, persons2.name AS womanname > FROM `weddings` > JOIN persons AS persons1 ON weddings.manid = persons1.id > JOIN persons AS persons2 ON weddings.womanid = persons2.id You are the best Paul! I myself came up with an slightly other way to do it. I'll paste it in later. In case anybody should care. Kasper K. |