Guest User

Untitled

a guest
Mar 22nd, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. DROP TABLE IF EXISTS `org_apiinteg_assets`;
  2. DROP TABLE IF EXISTS `assessmentinstances`;
  3.  
  4. CREATE TABLE `org_apiinteg_assets` (
  5. `id` varchar(20) NOT NULL default '0',
  6. `instance_id` varchar(20) default NULL,
  7. PRIMARY KEY (`id`)
  8. ) ENGINE= MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1;
  9.  
  10. CREATE TABLE `assessmentinstances` (
  11. `id` varchar(20) NOT NULL default '0',
  12. `title` varchar(180) default NULL,
  13. PRIMARY KEY (`id`)
  14. ) ENGINE= MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1;
  15.  
  16.  
  17. insert into assessmentinstances(id, title) values ('14026lvplotw6','One radio question survey');
  18. insert into org_apiinteg_assets(id, instance_id) values ('8kp9wgx43jflrgjfe','14026lvplotw6');
  19.  
  20. assessmentinstances
  21. +---------------+---------------------------+
  22. | id | title |
  23. +---------------+---------------------------+
  24. | 14026lvplotw6 | One radio question survey |
  25. +---------------+---------------------------+
  26.  
  27. org_apiinteg_assets
  28. +-------------------+---------------+
  29. | id | instance_id |
  30. +-------------------+---------------+
  31. | 8kp9wgx43jflrgjfe | 14026lvplotw6 |
  32. +-------------------+---------------+
  33.  
  34. SELECT ai.id, COUNT(*) AS `count`
  35. FROM assessmentinstances ai INNER JOIN org_apiinteg_assets a
  36. ON a.instance_id = ai.id
  37. WHERE ai.id = '14026lvplotw6'
  38. AND a.id != '8kp9wgx43jflrgjfe';
  39.  
  40. null, 0
  41.  
  42. '14026lvplotw6','0'
Add Comment
Please, Sign In to add comment