由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - SQL question...
相关主题
请问这个query怎么做error of sql query in MS Access database (转载)
最近写了不少SQL script,请大牛评价下属于什么水平怎样快速得到两个表的交集
Error of SQL query on IBM netezza SQL database from Aginity (转载)mysql 问题 (转载)
Help: "Operation Must Be Updatable Query"SQL question: update a field
菜鸟问题,急问一道SQL的题 (转载)
how to write this queryAnybody use postgreSQL?
请问个join的问题Oracle to buy SUN? (转载)
向大牛请教 query问题啊!请求SQL语句
相关话题的讨论汇总
话题: mysql话题: t1话题: table1话题: name2话题: name1
进入Database版参与讨论
1 (共1页)
s**********i
发帖数: 711
1
I use MySQL and got this question...
there are two tables, one with ID and corresponding name.
the other table has two columns of IDs, id1 and id2.
I need to write a query to get both names for id1 and id2...
xt
发帖数: 17532
2
Any detail please?
j**i
发帖数: 419
3

I am not familiar with MYSQL,
but I guess in Access,oracle etc you can do something like this:
select T1.Name as Name1,T3.ID1,T3.ID2,T3.name as Name2 from T1,(select * from
T2,T1 where T1.ID=T2.ID2) T3 where T1.id=t3.id1
/
You can add left or outer join according to the needs.
Basically first join on the first ID -"Translate one ID "
and use the query as Table.
Then join on second ID and got the second name.
Am I right?

【在 s**********i 的大作中提到】
: I use MySQL and got this question...
: there are two tables, one with ID and corresponding name.
: the other table has two columns of IDs, id1 and id2.
: I need to write a query to get both names for id1 and id2...

b*e
发帖数: 3845
4
don't understand your question. Do you mean you
want to get
name1,name2
name1,name2
...
name1,name2
for all the rows of table 2?
let me try:
select T1.name, T2.name from table1 as T1, table1 as T2, table2 as T3
where T1.ID = T3.Id and T2.Id=T3.ID
let me know if this works.

【在 s**********i 的大作中提到】
: I use MySQL and got this question...
: there are two tables, one with ID and corresponding name.
: the other table has two columns of IDs, id1 and id2.
: I need to write a query to get both names for id1 and id2...

k*******d
发帖数: 237
5

Select T2.id1, T1.Name, T2.id2, T3.Name
From Table1 T1, Table2 T2, Table1 T3
Where T2.id1=T1.ID and T2.id2=T3.ID

【在 s**********i 的大作中提到】
: I use MySQL and got this question...
: there are two tables, one with ID and corresponding name.
: the other table has two columns of IDs, id1 and id2.
: I need to write a query to get both names for id1 and id2...

b*e
发帖数: 3845
6
hehe, same as mine.

【在 k*******d 的大作中提到】
:
: Select T2.id1, T1.Name, T2.id2, T3.Name
: From Table1 T1, Table2 T2, Table1 T3
: Where T2.id1=T1.ID and T2.id2=T3.ID

s**********i
发帖数: 711
7
great. thanks a lot!

【在 b*e 的大作中提到】
: hehe, same as mine.
s**********i
发帖数: 711
8

I guess you probably right... but MySQL doesn't support
sub query thus your answer doesn't work on it...

【在 j**i 的大作中提到】
:
: I am not familiar with MYSQL,
: but I guess in Access,oracle etc you can do something like this:
: select T1.Name as Name1,T3.ID1,T3.ID2,T3.name as Name2 from T1,(select * from
: T2,T1 where T1.ID=T2.ID2) T3 where T1.id=t3.id1
: /
: You can add left or outer join according to the needs.
: Basically first join on the first ID -"Translate one ID "
: and use the query as Table.
: Then join on second ID and got the second name.

xt
发帖数: 17532
9

so if it has stored procedure you might want to use it.
No offense to open source projects, but I don't think MySQL
is really a good DBMS.

【在 s**********i 的大作中提到】
:
: I guess you probably right... but MySQL doesn't support
: sub query thus your answer doesn't work on it...

s**********i
发帖数: 711
10

it's not, but it's free... :)
I've heard the coming version would have sub query support though.

【在 xt 的大作中提到】
:
: so if it has stored procedure you might want to use it.
: No offense to open source projects, but I don't think MySQL
: is really a good DBMS.

相关主题
how to write this queryerror of sql query in MS Access database (转载)
请问个join的问题怎样快速得到两个表的交集
向大牛请教 query问题啊!mysql 问题 (转载)
进入Database版参与讨论
xt
发帖数: 17532
11

I don't worry about the price, since I can always get it free
from the house. hehe

【在 s**********i 的大作中提到】
:
: it's not, but it's free... :)
: I've heard the coming version would have sub query support though.

f***o
发帖数: 31
12

postgres.
mysql is supposed to be simple

【在 xt 的大作中提到】
:
: I don't worry about the price, since I can always get it free
: from the house. hehe

s**********i
发帖数: 711
13

yes. the point of MySQL is trade features for performance.

【在 f***o 的大作中提到】
:
: postgres.
: mysql is supposed to be simple

a*****i
发帖数: 4391
14
Use postgresql, light years ahead of that POS called MySQL. :)

【在 s**********i 的大作中提到】
:
: yes. the point of MySQL is trade features for performance.

s**********i
发帖数: 711
15

performance is much worse than MySQL...

【在 a*****i 的大作中提到】
: Use postgresql, light years ahead of that POS called MySQL. :)
a*****i
发帖数: 4391
16
Maybe you didn't tune it right?
I am not very familiar with MySQL though, but postgresql has quite some
spaces to fine-tune.

【在 s**********i 的大作中提到】
:
: performance is much worse than MySQL...

s**********i
发帖数: 711
17
MySQL is very fast in simple selects, and low cost
for connecting. this makes it one of the best choice
for web applications... there are some major companies
use MySQL for their web servers like yahoo, slashdot...

【在 a*****i 的大作中提到】
: Maybe you didn't tune it right?
: I am not very familiar with MySQL though, but postgresql has quite some
: spaces to fine-tune.

1 (共1页)
进入Database版参与讨论
相关主题
请求SQL语句菜鸟问题,急
紧急求助, 关于SQL Serverhow to write this query
问个SQL问题- partial outer join请问个join的问题
SQL combine two tables into one table and add a new column向大牛请教 query问题啊!
请问这个query怎么做error of sql query in MS Access database (转载)
最近写了不少SQL script,请大牛评价下属于什么水平怎样快速得到两个表的交集
Error of SQL query on IBM netezza SQL database from Aginity (转载)mysql 问题 (转载)
Help: "Operation Must Be Updatable Query"SQL question: update a field
相关话题的讨论汇总
话题: mysql话题: t1话题: table1话题: name2话题: name1