下記、MySQL上でtd_fh6800_1_readlogテーブルの先頭120行と、td_fh6800_1_writelogテーブルの先頭120行目から120行を取得するSQLがあります。
このそれぞれの実行結果で、td_fh6800_1_readlogテーブルの先頭120行を取得したデータと、td_fh6800_1_writelogテーブルの先頭120行目から120行を取得したデータで一致するデータを取得したいです
limit句を使うと、INNER JOINが使えませんでした。
ご教示の程、よろしくお願いします
select name,nom,suf from td_fh6800_1_readlog limit 120 select name,nom,suf from td_fh6800_1_writelog limit 120,120;
MySQLのバージョンと
該当のテーブルのテーブル定義と
サンプルデータと
join使ってみたSQLと
望む結果をご提示ください
ご回答ありがとうございます
下記、回答がわかりくい懸念がありますが、回答させていただきます。
MySQLバージョン5.7.25
テーブル定義
id int(10) UN AI PK
avf int(10) UN
tno smallint(5) UN
name tinyint(3) UN
part tinyint(3) UN
nom int(11)
itf tinyint(3) UN
suf tinyint(3) UN
sufatr tinyint(3) UN
pkno smallint(5) UN
lengthA double UN
lengthB double
lengthC double
diameter double
toolsetX bigint(20) UN
toolsetZ bigint(20) UN
rotate smallint(6)
mtr1 tinyint(3) UN
mtr2 tinyint(3) UN
mtr3 tinyint(3) UN
mtr4 tinyint(3) UN
mtr5 tinyint(3) UN
mtr6 tinyint(3) UN
mtr7 tinyint(3) UN
mtr8 tinyint(3) UN
mtr9 tinyint(3) UN
holdno smallint(6)
holdtype smallint(6)
lifetime float
usetime float
lifenumber smallint(5) UN
usenumber smallint(5) UN
gno int(11)
compno int(11)
idno tinyint(4)
wearcompX int(11)
wearcompZ int(11)
wearcompY int(11)
maxwearX int(11)
maxwearZ int(11)
maxwearY int(11)
model tinyint(4)
teyecompX int(11)
teyecompZ int(11)
holdlength int(11)
holddiam int(11)
sts int(11)
angle smallint(6)
index_select tinyint(3) UN
easycompX int(11)
easycompZ int(11)
easycompY int(11)
conscompX int(11)
conscompZ int(11)
conscompY int(11)
lengcomp int(11)
maxrotate int(11)
tipangle smallint(6)
radcomp int(11)
radcomp_no int(11)
lencomp int(11)
lencomp_no int(11)
anglecomp int(11)
cutang int(11)
edgang int(11)
holdwidth1 int(11)
holdwidth2 int(11)
twidth int(11)
lbbno tinyint(3) UN
edgwidth int(11)
grvdepth int(11)
taprfeed smallint(5) UN
taptype tinyint(3) UN
horsepower tinyint(3) UN
thrust tinyint(3) UN
teeth int(11)
cutdepth int(11)
cornerR int(11)
chamferangle int(11)
minimumdia int(11)
threshold smallint(5) UN
mc smallint(6) UN
tm timestamp
データ1レコード
3 0 3 13 0 100 0 0 0 0 2136150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6000 1200 0 0 1100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2021-02-10 11:34:24
SQLは
select name,nom,suf from td_fh6800_1_writelog limit 120 inner join select name,nom,suf from td_fh6800_1_readlog limit 120,120 on td_fh6800_1_writelog.name=td_fh6800_1_readlog.name and td_fh6800_1_writelog.nom=td_fh6800_1_readlog.nom and td_fh6800_1_writelog.nom=td_fh6800_1_readlog.nom and d_fh6800_1_writelog.suf=td_fh6800_1_readlog.suf;
エラー内容
12:49:26 select name,nom,suf from td_fh6800_1_writelog limit 120 inner join select name,nom,suf from td_fh6800_1_readlog limit 120,120 on td_fh6800_1_writelog.name=td_fh6800_1_readlog.name and td_fh6800_1_writelog.nom=td_fh6800_1_readlog.nom and td_fh6800_1_writelog.nom=td_fh6800_1_readlog.nom and d_fh6800_1_writelog.suf=td_fh6800_1_readlog.suf Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'inner join select name,nom,suf from td_fh6800_1_readlog limit 120,120 on td_fh6' at line 1 0.000 sec
望む結果はtd_fh6800_1_writelogテーブルにないtd_fh6800_1_readlogテーブルのデータを取りたいです。td_fh6800_1_writelogテーブルとtd_fh6800_1_readlogテーブルには同じレコードが数件存在しています。
回答1件
あなたの回答
tips
プレビュー