mysql> select * from syohin_tbl inner join hanbai_tbl
on syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | syohincode | price | hanbaibi |
+------------+------------+------------+------------+-------------+------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | G02002 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | B03003 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | A01001 | 100 | 2003-05-01 |
| M02005 | M02 | meron | H01010 | 0072 | M02005 | 600 | 2003-05-03 |
| P01004 | P01 | peach | H01020 | 0002 | P01004 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B>e5-$NNc$G$O!"%U%#!<%k%I$r;XDj$7$J$$$?$a$9$Y$F$N%U%#!<%k%I(B
$B$r4^$s$@%F!<%V%k$,:n@.!"I=<($5$l$F$$$k!#(B
$B$r;XDj$7$F!"F1$8%U%#!<%k%I$,=EJ#$7$J$$$h$&(B
$B%F!<%V%k$r:n@.!"I=<($7$F$_$h$&!#(B
mysql> select syohin_tbl.syohincode, syohin_tbl.bunruicode, syohin_tbl.syohinname,
hanbai_tbl.hanbaicode, hanbai_tbl.kokyakucode, hanbai_tbl.price, hanbai_tbl.hanbaibi
from syohin_tbl inner join hanbai_tbl
on syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | price | hanbaibi |
+------------+------------+------------+------------+-------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | 100 | 2003-05-01 |
| M02005 | M02 | meron | H01010 | 0072 | 600 | 2003-05-03 |
| P01004 | P01 | peach | H01020 | 0002 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B$5$i$K!"%U%#!<%k%IL>$rA*Br!&;XDj$7$?%F!<%V%k$r:n@.$9$k$H(B
$B0J2<$N$h$&$K$J$k!#(B
mysql> select syohin_tbl.syohinname, hanbai_tbl.kokyakucode, hanbai_tbl.hanbaibi, hanbai_tbl.price
from syohin_tbl inner join hanbai_tbl
on syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+-------------+------------+-------+
| syohinname | kokyakucode | hanbaibi | price |
+------------+-------------+------------+-------+
| grape | 2121 | 2003-04-12 | 130 |
| banana | 3211 | 2003-04-29 | 90 |
| apple | 1001 | 2003-05-01 | 100 |
| meron | 0072 | 2003-05-03 | 600 |
| peach | 0002 | 2003-05-10 | 150 |
+------------+-------------+------------+-------+
5 rows in set (0.00 sec)
mysql>
[WHERE$B6g$NMxMQ(B]
$B>e5-$N(BINNER JOIN$B6g$K$h$kFbIt7k9g$HF1MM$JA`:n$r0J2<$N(BWHERE$B6g$r(B
$B;H$C$F$*$3$J$&$3$H$,$G$-$k!#(B
WHERE$B6g$K$h$kFbIt7k9g$G$O!"(BSELECT$BJ8$r;H$$!"7k9g@h$N%F!<%V%kL>$H(B
INNER JOIN$B6g$N>r7o<0$r5-=R$9$k!#(BSELECT$BJ8$N;H$C$?9=J8$O!"0J2<$N(B
$B$h$&$K$J$k!#(B
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>#1(B, $B%F!<%V%kL>#2(B where $B7k9g>r7o!J%F!<%V%kL>#1(B.$B%U%#!<%k%IL>#3(B = $B%F!<%V%kL>#2(B.$B%U%#!<%k%IL>#3!K(B;
INNER JOIN$B6g$NNc$rMQ$$$F!"FbIt7k9g$K$h$k%F!<%V%k$r:n@.$7$F$_$h$&!#(B
$B$^$:!"$9$Y$F$N%U%#!<%k%IL>$r4^$`%F!<%V%k$r:n@.!"I=<($7$F$_$h$&!#(B
mysql> select * from syohin_tbl, hanbai_tbl
where syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | syohincode | price | hanbaibi |
+------------+------------+------------+------------+-------------+------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | G02002 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | B03003 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | A01001 | 100 | 2003-05-01 |
| M02005 | M02 | meron | H01010 | 0072 | M02005 | 600 | 2003-05-03 |
| P01004 | P01 | peach | H01020 | 0002 | P01004 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B>e5-$NNc$G$O!"%U%#!<%k%I$r;XDj$7$J$$$?$a$9$Y$F$N%U%#!<%k%I$r4^$s$@%F!<%V%k$,:n@.!"I=<($5$l$F$$$k!#(B
$B$r;XDj$7$F!"F1$8%U%#!<%k%I$,=EJ#$7$J$$$h$&%F!<%V%k$r:n@.!"I=<($7$F$_$h$&!#(B
mysql> select syohin_tbl.syohincode, syohin_tbl.bunruicode, syohin_tbl.syohinname,
hanbai_tbl.hanbaicode, hanbai_tbl.kokyakucode, hanbai_tbl.price, hanbai_tbl.hanbaibi
from syohin_tbl, hanbai_tbl
where syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | price | hanbaibi |
+------------+------------+------------+------------+-------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | 100 | 2003-05-01 |
| M02005 | M02 | meron | H01010 | 0072 | 600 | 2003-05-03 |
| P01004 | P01 | peach | H01020 | 0002 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B$5$i$K!"%U%#!<%k%IL>$rA*Br!&;XDj$7$?%F!<%V%k$r:n@.$9$k$H0J2<$N$h$&$K$J$k!#(B
mysql> select syohin_tbl.syohinname, hanbai_tbl.kokyakucode, hanbai_tbl.hanbaibi, hanbai_tbl.price from syohin_tbl, hanbai_tbl
where syohin_tbl.syohincode = hanbai_tbl.syohincode;
+------------+-------------+------------+-------+
| syohinname | kokyakucode | hanbaibi | price |
+------------+-------------+------------+-------+
| grape | 2121 | 2003-04-12 | 130 |
| banana | 3211 | 2003-04-29 | 90 |
| apple | 1001 | 2003-05-01 | 100 |
| meron | 0072 | 2003-05-03 | 600 |
| peach | 0002 | 2003-05-10 | 150 |
+------------+-------------+------------+-------+
5 rows in set (0.00 sec)
mysql>
$B-6(B. $B30It7k9g(B
$B30It7k9g$G$O!"7k9g@h$N%F!<%V%k$K3:Ev$9$k%G!<%?$,$J$/$F$b!"(B
$B7k2L$r5a$a$F%F!<%V%k$r:n@.$G$-$k!#(B
$B30It7k9g$K$O!"0J2<$N#2$D$,$"$k!#(B
- LEFT JOIN$B6g$NMxMQ(B
- RIGTH JOIN$B6g$NMxMQ(B
$B30It7k9g$O!":81&%F!<%V%k$N7k9gJ}K!$K$h$j7k9g7k2L$,0[$J$k(B
$B$3$H$KCm0U$,I,MW$G$"$k!#:8B&$N%F!<%V%k$rM%@h$9$k30It7k9g$r(B
$B:830It7k9g$H$$$&!#0lJ}!"1&B&$N%F!<%V%k$rM%@h$9$k30It7k9g$r(B
$B1&30It7k9g$H$$$&!#:830It7k9g$O!"7k9g@h$N1&B&$K$"$k%F!<%V%k(B
$B$K3:Ev$9$k%G!<%?$,$J$/$F$b!"(BNULL$BCM$GCV$-49$($i$l$?%G!<%?$r(B
$B4^$`%F!<%V%k$,@8@.$5$l$k!#(B
[$B:830It7k9g(B]
LEFT JOIN$B6g$r;XDj$7$F:830It7k9g$r$*$3$J$&(BSQL$B9=J8$O!"(B
$B
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>#1(B
left join $B%F!<%V%kL>#2(B on $B7k9g>r7o!J%F!<%V%kL>#1(B.$B%U%#!<%k%IL>#3(B = $B%F!<%V%kL>#2(B.$B%U%#!<%k%IL>#3!K(B;
$B0J2<$G$O!"?7$?$J%F!<%V%k$H$7$F!"0J2<$N$h$&$J(Bsyohin_tbl1
$B%F!<%V%k$rDj5A$9$k!#%F!<%V%k$N9=B$$O!"(Bsyohin_tbl$B%F!<%V%k(B
$B$HF1MM$G$"$k!#(B
syohin_tbl1$B%F!<%V%k$N9=B$(B
$BNsL>(B | $B%G!<%?7?(B | NOT NULL |
syohincode | VARCHAR(10) | NOT NULL |
bunruicode | VARCHAR(5) |
|
syohinname | VARCHAR(100) |
|
syohin_tbl1$B%F!<%V%k(B
syohincode | bunruicode | syohinname |
A01001 | A01 | apple |
G02002 | G02 | grape |
B03003 | B03 | banana |
X04001 | X04 | ice_cream |
Y02007 | Y02 | chocolate |
LEFT JOIN$B6g$r;XDj$7$?:830It7k9g$G$O!"(Bsyohin_tbl1$B%F!<%V%k(B
$B$H(Bhanbai_tbl$B%F!<%V%k$K(B
$B$*$$$F!"(Bsyohin_tbl1$B%F!<%V%k$KEPO?$5$l$F$$$k%l%3!<%I$r(B
$BM%@h$7$F(Bsyohincode$B%U%#!<%k%IL>$NCM$,Ey$7$$%l%3!<%IF1;N(B
$B$r7k9g$9$k!#(B
$B$r4^$`%F!<%V%k$N:n@.!&
mysql> select * from syohin_tbl1 left join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | syohincode | price | hanbaibi |
+------------+------------+------------+------------+-------------+------------+-------+------------+
| A01001 | A01 | apple | H01005 | 1001 | A01001 | 100 | 2003-05-01 |
| G02002 | G02 | grape | H01001 | 2121 | G02002 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | B03003 | 90 | 2003-04-29 |
| X04001 | X04 | ice_cream | NULL | NULL | NULL | NULL | NULL |
| Y02007 | Y02 | chocolate | NULL | NULL | NULL | NULL | NULL |
+------------+------------+------------+------------+-------------+------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B%U%#!<%k%IL>$r;XDj$7$F!"F1$8%U%#!<%k%I$,=EJ#$7$J$$$h$&%F!<%V%k$r:n@.!"I=<($7$F$_$k$H!"
mysql> select syohin_tbl1.syohincode, syohin_tbl1.bunruicode, syohin_tbl1.syohinname,
hanbai_tbl.hanbaicode, hanbai_tbl.kokyakucode, hanbai_tbl.price,
hanbai_tbl.hanbaibi from syohin_tbl1 left join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | price | hanbaibi |
+------------+------------+------------+------------+-------------+-------+------------+
| A01001 | A01 | apple | H01005 | 1001 | 100 | 2003-05-01 |
| G02002 | G02 | grape | H01001 | 2121 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | 90 | 2003-04-29 |
| X04001 | X04 | ice_cream | NULL | NULL | NULL | NULL |
| Y02007 | Y02 | chocolate | NULL | NULL | NULL | NULL |
+------------+------------+------------+------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B$5$i$K!"%U%#!<%k%IL>$rA*Br!&;XDj$7$?%F!<%V%k$r:n@.$9$k$H0J2<$N$h$&$K$J$k!#(B
mysql> select syohin_tbl1.syohinname, hanbai_tbl.kokyakucode, hanbai_tbl.hanbaibi, hanbai_tbl.price
from syohin_tbl1 left join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+-------------+------------+-------+
| syohinname | kokyakucode | hanbaibi | price |
+------------+-------------+------------+-------+
| apple | 1001 | 2003-05-01 | 100 |
| grape | 2121 | 2003-04-12 | 130 |
| banana | 3211 | 2003-04-29 | 90 |
| ice_cream | NULL | NULL | NULL |
| chocolate | NULL | NULL | NULL |
+------------+-------------+------------+-------+
5 rows in set (0.01 sec)
mysql>
[$B1&30It7k9g(B]
$B1&30It7k9g$G$O:830It7k9g$H$O5U$K!"1&B&$N%F!<%V%k$rM%@h$7$F7k9g(B
$B$9$k!#6qBNE*$K$$$&$H!":8B&$K$"$k%F!<%V%kL>(B1$B$H1&B&$K$"$k%F!<%V%kL>(B2
$B$N%l%3!<%I$G!"%F!<%V%kL>(B2$B$KEPO?$5$l$F$$$k%l%3!<%I$rM%@h$7$F!"7k9g(B
$B>r7o$rK~B-$9$k%l%3!<%IF1;N$r7k9g$7$F%F!<%V%k$r:n@.$9$k!#(B
$B$3$l$r(BRIGHT JOIN$B6g$r;XDj$7$F1&30It7k9g$r$*$3$J$&$?$a$K$O!"(B
$B
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>#1(B
right join $B%F!<%V%kL>#2(B on $B7k9g>r7o!J%F!<%V%kL>#1(B.$B%U%#!<%k%IL>#3(B = $B%F!<%V%kL>#2(B.$B%U%#!<%k%IL>#3!K(B;
$B$r4^$`%F!<%V%k$N:n@.!&
mysql> select * from syohin_tbl1 right join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | syohincode | price | hanbaibi |
+------------+------------+------------+------------+-------------+------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | G02002 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | B03003 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | A01001 | 100 | 2003-05-01 |
| NULL | NULL | NULL | H01010 | 0072 | M02005 | 600 | 2003-05-03 |
| NULL | NULL | NULL | H01020 | 0002 | P01004 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B%U%#!<%k%IL>$r;XDj$7$F!"F1$8%U%#!<%k%I$,=EJ#$7$J$$$h$&%F!<%V%k$r:n@.!"I=<($7$F$_$k$H!"
mysql> select hanbai_tbl.syohincode, syohin_tbl1.bunruicode, syohin_tbl1.syohinname,
hanbai_tbl.hanbaicode, hanbai_tbl.kokyakucode, hanbai_tbl.price,
hanbai_tbl.hanbaibi from syohin_tbl1 right join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+------------+------------+------------+-------------+-------+------------+
| syohincode | bunruicode | syohinname | hanbaicode | kokyakucode | price | hanbaibi |
+------------+------------+------------+------------+-------------+-------+------------+
| G02002 | G02 | grape | H01001 | 2121 | 130 | 2003-04-12 |
| B03003 | B03 | banana | H01003 | 3211 | 90 | 2003-04-29 |
| A01001 | A01 | apple | H01005 | 1001 | 100 | 2003-05-01 |
| M02005 | NULL | NULL | H01010 | 0072 | 600 | 2003-05-03 |
| P01004 | NULL | NULL | H01020 | 0002 | 150 | 2003-05-10 |
+------------+------------+------------+------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql>
$B$5$i$K!"%U%#!<%k%IL>$rA*Br!&;XDj$7$?%F!<%V%k$r:n@.$9$k$H0J2<$N$h$&$K$J$k!#(B
mysql> select hanbai_tbl.syohincode, syohin_tbl1.syohinname, hanbai_tbl.kokyakucode,
hanbai_tbl.hanbaibi, hanbai_tbl.price
from syohin_tbl1 right join hanbai_tbl
on syohin_tbl1.syohincode = hanbai_tbl.syohincode;
+------------+------------+-------------+------------+-------+
| syohincode | syohinname | kokyakucode | hanbaibi | price |
+------------+------------+-------------+------------+-------+
| G02002 | grape | 2121 | 2003-04-12 | 130 |
| B03003 | banana | 3211 | 2003-04-29 | 90 |
| A01001 | apple | 1001 | 2003-05-01 | 100 |
| M02005 | NULL | 0072 | 2003-05-03 | 600 |
| P01004 | NULL | 0002 | 2003-05-10 | 150 |
+------------+------------+-------------+------------+-------+
5 rows in set (0.00 sec)
mysql>
$B-7(B. $B%f%K%*%s$K$h$k7k9g!!(B
$BFbIt7k9g$d30It7k9g$,%F!<%V%k$r:81&J}8~$K7k9g$5$;$k(B
$B$b$N$G$"$k$N$KBP$7$F!"%f%K%*%s$O7k9g7k2L$r>e2
$B%f%K%*%s$K$h$k7k9g$r$*$3$J$&$K$O!"7k9g$9$k%F!<%V%kF1;N!"(B
$B$^$?$O!"F1$8%U%#!<%k%IL>$r$b$D%F!<%V%k9=B$$G$"$k$3$H$,(B
$BI,MW$G$"$k!#(B
$B%f%K%*%s$K$h$k7k9g$r$*$3$J$&$?$a$K!"#2$D$N%F!<%V%k$r%^!<%8%F!<%V%k(B
$B5!G=(B(merge union)$B$r;H$C$F7k9g$9$k!#$^$:!"%^!<%8$5$l$?%l%3!<%I$r(B
$B3JG<$9$k%F!<%V%k$r:n@.$7!"
$B%f%K%*%s$K$h$k7k9g$G$O!"
mysql> select * from $B%F!<%V%kL>#1(B union select * from $B%F!<%V%kL>#2(B;
$B]$H$9$k%F!<%V%k$O!"0J2<$N$h$&$J(Bshinamono_tbl1$B$H(B
shinamono_tbl2$B$H$9$k!#(B
shinamono_tbl$B%F!<%V%k$N9=B$(B
$BNsL>(B | $B%G!<%?7?(B | NOT NULL |
shinamonocode | VARCHAR(10) | NOT NULL |
shinamoname | VARCHAR(20) |
|
shinamono_tbl1$B%F!<%V%k(B
shinamonocode | shinamononame |
A001 | apple |
A002 | orange |
A003 | banana |
A004 | grape |
shinamono_tbl2$B%F!<%V%k(B
shinamonocode | shinamononame |
B001 | tomato |
B002 | cabbage |
B003 | potato |
B004 | corn |
shinamono_tbl1$B$H(Bshinamono_tbl2$B$r%f%K%*%s$r;H$C$F7k9g$9$k$?$a$K$O!"(B
$B0J2<$N(BSQL$B%3%^%s%I$,I,MW$K$J$k!#
mysql> select * from shinamono_tbl1 union select * from shinamono_tbl2;
+---------------+-------------+
| shinamonocode | shinamoname |
+---------------+-------------+
| A001 | apple |
| A002 | orange |
| A003 | banana |
| A004 | grape |
| B001 | tomato |
| B002 | cabbage |
| B003 | potato |
| B004 | corn |
+---------------+-------------+
8 rows in set (0.00 sec)
mysql>
$B-8(B. $B<+8J7k9g(B
$B<+8J7k9g$G$O!"F1$8%F!<%V%kF1;N$r7k9g$9$k!#$?$@$7!"7k9g;~$K(B
$B;XDj$9$k%-!<$H%U%#!<%k%IL>$,A4$/F1$8$K$J$C$F$7$^$&$N$G!"(B
$BJLL>$r;XDj$9$k$J$I$NCm0U$,I,MW$H$J$k!#(B
$B<+8J7k9g$r$*$3$J$&(BSQL$BJ8$O!"0J2<$N$h$&$K$J$k!#(B
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>(B
as $BJLL>(B1, $B%F!<%V%kL>(B as $BJLL>(B2 where $B7k9g>r7o!JJLL>#1(B.$B%U%#!<%k%IL>(B = $BJLL>#2(B.$B%U%#!<%k%IL>!K(B;
$B
mysql> select * from shinamono_tbl1 as st1, shinamono_tbl1 as st2
where st1.shinamonocode = st2.shinamonocode;
+---------------+---------------+---------------+---------------+
| shinamonocode | shinamononame | shinamonocode | shinamononame |
+---------------+---------------+---------------+---------------+
| A001 | apple | A001 | apple |
| A002 | orange | A002 | orange |
| A003 | banana | A003 | banana |
| A004 | grape | A004 | grapea |
+---------------+---------------+---------------+---------------+
4 rows in set (0.00 sec)
mysql>
$B-9(B. $B8r:97k9g!!(B
$B8r:97k9g$O!"#2$D$N%F!<%V%k$N$"$i$f$k%G!<%?F1;N$rAH$_9g$o$;$k(B
$B7k9g$G$"$k!#7k9g8e$N%G!<%??t$,#2$D$N%F!<%V%k$N@Q$K$J$k$N$G!"(B
$BF@$i$l$k7k2L$,KDBg$K$J$k$N$GCm0U$,I,MW$G$"$k!#(B
$B8r:97k9g$r$*$3$J$&$?$a$K$O!"
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>(B1, $B%F!<%V%kL>(B2;
$B8r:97k9g$O!"0J2<$N9=J8$G$bF1MM$JA`:n$K$h$j
mysql> select $B%U%#!<%k%IL>#1(B, $B%U%#!<%k%IL>#2(B, .... from $B%F!<%V%kL>(B1 cross join $B%F!<%V%kL>(B2;
$B
mysql> select * from shinamono_tbl1, shinamono_tbl2;
+---------------+---------------+---------------+---------------+
| shinamonocode | shinamononame | shinamonocode | shinamononame |
+---------------+---------------+---------------+---------------+
| A001 | apple | B001 | tomato |
| A002 | orange | B001 | tomato |
| A003 | banana | B001 | tomato |
| A004 | grape | B001 | tomato |
| A001 | apple | B002 | cabbage |
| A002 | orange | B002 | cabbage |
| A003 | banana | B002 | cabbage |
| A004 | grape | B002 | cabbage |
| A001 | apple | B003 | potato |
| A002 | orange | B003 | potato |
| A003 | banana | B003 | potato |
| A004 | grape | B003 | potato |
| A001 | apple | B004 | corn |
| A002 | orange | B004 | corn |
| A003 | banana | B004 | corn |
| A004 | grape | B004 | corn |
+---------------+---------------+---------------+---------------+
16 rows in set (0.00 sec)
mysql>
mysql>
$BLdBj(B-0
$B>e5-$G@bL@$7$?%3%^%s%I$r$9$Y$F
$BLdBj(B-1
fruit$B%F!<%V%k$+$i(Bprice$B%U%#!<%k%I$NCM$,(B100$B0J>e$N%G!<%?!J%l%3!<%I!K7o?t$r5a$a!"(B
$BI=<($;$h!#(B
$BLdBj(B-2
fruit$B%F!<%V%k$+$i(Bprice$B%U%#!<%k%I$NCM$N9g7W$r5a$a!"(B
$B$=$N7k2L$rI=<($;$h!#$=$N:]$KMQ$$$?%3%^%s%I$r<($9$3$H!#(B
$BLdBj(B-3
fruit$B%F!<%V%k$+$i(Bprice$B%U%#!<%k%I$NCM$NJ?6Q$r5a$a!"(B
$B$=$N7k2L$rI=<($;$h!#$=$N:]$KMQ$$$?%3%^%s%I$r<($9$3$H!#(B
$BLdBj(B-4
fruit$B%F!<%V%k$+$i(Bprice$B%U%#!<%k%I$NCM$N:GBgCM$r5a$a!"(B
$B$=$N7k2L$rI=<($;$h!#$=$N:]$KMQ$$$?%3%^%s%I$r<($9$3$H!#(B
$BLdBj(B-5
$BFbIt7k9g$H30It7k9g$N0c$$$r6qBNE*$J;vNc$rMQ$$$F@bL@$;$h!#(B
$BLdBj(B-6
$B:830It7k9g$H1&30It7k9g$N0c$$$r6qBNE*$J;vNc$rMQ$$$F@bL@$;$h!#(B
$BLdBj(B-7
fruit$B%F!<%V%k$r<+8J7k9g$7!"$=$N7k2L$rI=<($;$h!#(B
$B$=$N:]$KMQ$$$?%3%^%s%I$r<($9$3$H!#(B
$BLdBj(B-8
$B30It7k9g$N2r@b$K$"$k!"(Bsyohin_tbl1$B$H(Bhanbai_tbl$B$N:81&$N=gHV$r5UE>$7!":8$r(Bhanbai_tbl,
$B1&$r(Bsyohin_tbl1$B$K$;$h!#$=$7$F!"2r@b$K$"$k:830It7k9g$H1&30It7k9g$N$=$l$>$l$HF1$87k2L(B
$B$r=P$9(BSQL$BJ8$r:n@.$7!"
$BLdBj(B-9
$B8r:97k9g$N2r@b$K$"$k!"(Bshinamono_tbl1$B$H(Bshinamono_tbl2$B$N8r:97k9g$,$J$<(B16$B9T$K$J$k$+$r@bL@(B
$B$;$h!#(B
$B%7%9%F%`%W%m%0%i%_%s%01i=,(B
Yasuo NAGAI