由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - mysql mapping and insert question
相关主题
How to split a column into several rows?请问如何实现这样一个mysql的query, 谢谢
mySQL 问题 (转载)SQL Server insert speed too slow! Help?
谁能帮我看看这个Insert语句要怎么改一下?sql query help
SQL 2008 Group By Question菜鸟问题,急
请教一个SQL的问题A rookie's query question
SQL copy a table into a new table and add a new column问个sql/ ssis的问题 谢谢!
SQL select one value column for each distinct value another (转载)sql 请教
How to lock tabel with LINQ to SQL (转载)一个oracle performance 的问题。
相关话题的讨论汇总
话题: col话题: insert话题: mapping话题: db话题: mysql
进入Database版参与讨论
1 (共1页)
c*******o
发帖数: 1722
1
have a table tab_a with col_1 and col_2, now i need to map col_1 to
something and insert the results into col_2. for example, if col_1 = 17 then
insert col_2 as "Region 1". how do i do this? thanks a lot.
B*****g
发帖数: 34098
2
case

then

【在 c*******o 的大作中提到】
: have a table tab_a with col_1 and col_2, now i need to map col_1 to
: something and insert the results into col_2. for example, if col_1 = 17 then
: insert col_2 as "Region 1". how do i do this? thanks a lot.

a9
发帖数: 21638
3
触发器?

then

【在 c*******o 的大作中提到】
: have a table tab_a with col_1 and col_2, now i need to map col_1 to
: something and insert the results into col_2. for example, if col_1 = 17 then
: insert col_2 as "Region 1". how do i do this? thanks a lot.

c*******o
发帖数: 1722
4
can you write a simple example? i know little about mysql. thx

【在 B*****g 的大作中提到】
: case
:
: then

c*******o
发帖数: 1722
5
i know how to use the case:
select case col_1
when '17' then 'Region 1'
else row
end as value
from tab_a
and i know insert
insert into tab_a (col_2) values(value)
but how to combine them together?

【在 B*****g 的大作中提到】
: case
:
: then

B*****g
发帖数: 34098
6
update ...
set col2 = case when col1 = xx then 'xxxx' else 'xx' end

【在 c*******o 的大作中提到】
: can you write a simple example? i know little about mysql. thx
c*******o
发帖数: 1722
7
slick, dude. done.

【在 B*****g 的大作中提到】
: update ...
: set col2 = case when col1 = xx then 'xxxx' else 'xx' end

c*******o
发帖数: 1722
8
have a follow up question. what about
set col_2 = case when col_1 = xx, xx, xx then 'xxxx' else 'xx' end;
for multiple to one mapping? just want to save some typing. thx

【在 B*****g 的大作中提到】
: update ...
: set col2 = case when col1 = xx then 'xxxx' else 'xx' end

B*****g
发帖数: 34098
9
col1 in (......)

【在 c*******o 的大作中提到】
: have a follow up question. what about
: set col_2 = case when col_1 = xx, xx, xx then 'xxxx' else 'xx' end;
: for multiple to one mapping? just want to save some typing. thx

c*******o
发帖数: 1722
10
dude, you saved my day.

【在 B*****g 的大作中提到】
: col1 in (......)
相关主题
SQL copy a table into a new table and add a new column请问如何实现这样一个mysql的query, 谢谢
SQL select one value column for each distinct value another (转载)SQL Server insert speed too slow! Help?
How to lock tabel with LINQ to SQL (转载)sql query help
进入Database版参与讨论
B*****g
发帖数: 34098
11
呵呵,今天不上班,心情好。要不一般我会给你google link,不过那样能提高你的水
平。

【在 c*******o 的大作中提到】
: dude, you saved my day.
c*******o
发帖数: 1722
12
hoho.. thanks. i will come to this board more often. DB is useful.
DB operations seem so fast, I have been wondering why? if I pull data out
and do some similar operations in outside, the performance will be much
worse than doing so in DB.

【在 B*****g 的大作中提到】
: 呵呵,今天不上班,心情好。要不一般我会给你google link,不过那样能提高你的水
: 平。

a9
发帖数: 21638
13
编程功夫还不够啊。

的水

【在 c*******o 的大作中提到】
: hoho.. thanks. i will come to this board more often. DB is useful.
: DB operations seem so fast, I have been wondering why? if I pull data out
: and do some similar operations in outside, the performance will be much
: worse than doing so in DB.

s****i
发帖数: 36
14
Interesting.
It merely depends on what nature ur project is. Here we were advised to move
logic out of SQL as more as possible, as it's a web application and the cos
t of SQL server is much more expensive then that of a web server. We constan
tly encountered sql lock issues due to frequent operation to the database.

【在 c*******o 的大作中提到】
: hoho.. thanks. i will come to this board more often. DB is useful.
: DB operations seem so fast, I have been wondering why? if I pull data out
: and do some similar operations in outside, the performance will be much
: worse than doing so in DB.

a9
发帖数: 21638
15
你移到逻辑层锁不更严重啦。

move
cos
constan
out

【在 s****i 的大作中提到】
: Interesting.
: It merely depends on what nature ur project is. Here we were advised to move
: logic out of SQL as more as possible, as it's a web application and the cos
: t of SQL server is much more expensive then that of a web server. We constan
: tly encountered sql lock issues due to frequent operation to the database.

c*******o
发帖数: 1722
16
i am totally new in DB. i guess there is always a line.
what amazed me is that DB operationg seems very fast to me.

move
cos
constan

【在 s****i 的大作中提到】
: Interesting.
: It merely depends on what nature ur project is. Here we were advised to move
: logic out of SQL as more as possible, as it's a web application and the cos
: t of SQL server is much more expensive then that of a web server. We constan
: tly encountered sql lock issues due to frequent operation to the database.

1 (共1页)
进入Database版参与讨论
相关主题
一个oracle performance 的问题。请教一个SQL的问题
问个简单的sql语句SQL copy a table into a new table and add a new column
请教一个SQL Server的面试题SQL select one value column for each distinct value another (转载)
Access 里面两个 column不一样的table 能combine 到一起吗?How to lock tabel with LINQ to SQL (转载)
How to split a column into several rows?请问如何实现这样一个mysql的query, 谢谢
mySQL 问题 (转载)SQL Server insert speed too slow! Help?
谁能帮我看看这个Insert语句要怎么改一下?sql query help
SQL 2008 Group By Question菜鸟问题,急
相关话题的讨论汇总
话题: col话题: insert话题: mapping话题: db话题: mysql