如何在这两个表之间获取相关数据

时间:2017-03-21 12:17:03

标签: mysql

我有两个名字 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');

这是我的小提琴 http://sqlfiddle.com/#!9/0a9476/1

我们可以编写一个select查询,以便为pricechangeimpwl的每个符号获取suppourt1,suppourt2和suppourt3值吗?

1 个答案:

答案 0 :(得分:0)

select * from pricechangeimpwl p JOIN suppourtimpwl s
on p.name = s.name;