我有两张桌子,分别是pricechangeimpwl和suppourtimpwl
这两个表的名称相同。
这是我的图式
CREATE TABLE IF NOT EXISTS `pricechangeimpwl` (
`name` varchar(100) DEFAULT NULL,
`p1` decimal(10,2) DEFAULT NULL,
`time1` varchar(100) DEFAULT NULL,
`p2` decimal(10,2) DEFAULT NULL,
`time2` varchar(100) DEFAULT NULL,
`whatnext` varchar(50) DEFAULT NULL,
`stock_low` decimal(6,2) DEFAULT NULL,
`buy_sell_diff` varchar(100) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `pricechangeimpwl` (`name`, `p1`, `time1`, `p2`, `time2`, `whatnext`, `stock_low`, `buy_sell_diff`) VALUES
('DIVISLAB', 631.75, '2017-03-21 15:29:09', 630.85, '2017-03-21 15:40:47', 'plzcontinue', 628.60, '-417055'),
('M&M', 1297.00, '2017-03-21 15:29:09', 1299.00, '2017-03-21 15:40:47', 'plzcontinue', 1271.00, '9190');
-- Dumping structure for table trade_chit_chat.suppourtimpwl
CREATE TABLE IF NOT EXISTS `suppourtimpwl` (
`name` varchar(100) DEFAULT NULL,
`suppourt1` decimal(10,2) DEFAULT NULL,
`suppourt2` decimal(10,2) DEFAULT NULL,
`suppourt3` decimal(10,2) DEFAULT NULL,
`date` varchar(100) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `suppourtimpwl` (`name`, `suppourt1`, `suppourt2`, `suppourt3`, `date`) VALUES
('DIVISLAB', 762.54, 752.68, 739.35, '20 March 2017'),
('M&M', 1292.25, 1284.30, 1273.41, '20 March 2017');
这是我的SQL小提琴
http://sqlfiddle.com/#!9/0a9476/1
我们可以编写一个选择查询,以便它为pricechangeimpwl的每个符号获取suppourt1,suppourt2和suppourt3值吗?
最佳答案
select * from pricechangeimpwl p JOIN suppourtimpwl s
on p.name = s.name;
关于mysql - 如何在这两个表之间获取相关数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42926926/