Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. CREATE PROCEDURE checando (IN Businesstype VARCHAR (30))
  2. BEGIN
  3. IF (Businesstype = 'Comprar')
  4. THEN
  5. SELECT
  6. property_configs.`id` AS campaignID,
  7. property_configs.`value` AS campaignValue,
  8. properties.`id` AS propertyID,
  9. properties.`publicCode`,
  10. properties.`city`,
  11. properties.`neighborhood`,
  12. properties.`rentValue`,
  13. properties.`businessType`,
  14. properties.`propertyType`,
  15. properties.`state`
  16. FROM
  17. properties
  18. LEFT JOIN property_configs
  19. ON (
  20. property_configs.property_id = properties.id
  21. )
  22. WHERE properties.`businessType` = 'SELL' ;
  23.  
  24. ELSEIF (Businesstype = 'Alugar')
  25. THEN
  26. SELECT
  27. property_configs.`id` AS campaignID,
  28. property_configs.`value` AS campaignValue,
  29. properties.`id` AS propertyID,
  30. properties.`publicCode`,
  31. properties.`city`,
  32. properties.`neighborhood`,
  33. properties.`rentValue`,
  34. properties.`businessType`,
  35. properties.`propertyType`,
  36. properties.`state`
  37. FROM
  38. properties
  39. LEFT JOIN property_configs
  40. ON (
  41. property_configs.property_id = properties.id
  42. )
  43. WHERE properties.`businessType` = 'RENT' ;
  44.  
  45. ELSE
  46. SELECT
  47. property_configs.`id` AS campaignID,
  48. property_configs.`value` AS campaignValue,
  49. properties.`id` AS propertyID,
  50. properties.`publicCode`,
  51. properties.`city`,
  52. properties.`neighborhood`,
  53. properties.`rentValue`,
  54. properties.`businessType`,
  55. properties.`propertyType`,
  56. properties.`state`
  57. FROM
  58. properties
  59. LEFT JOIN property_configs
  60. ON (
  61. property_configs.`property_id` = properties.`id`
  62. ) ;
  63.  
  64. END IF ;
  65.  
  66. END //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement