Dave IT
asked on
How to use mysql statement to select and display only
First select the range of cc code when cc code >80000 and cc code <90000 , then replace the cc code when the cc code is on the range but the cc code is based on the cc code from table 2 then loop it based on the count column and only display cc code 1 and cc code 2. So how the mysql selection for this?
Picture_2.PNG
Picture_3.PNG
Picture 1 is my table 1
Picture 2 is my table 2
Picture 2 is my desire outputPicture_1.PNG
Picture_2.PNG
Picture_3.PNG
your code look like this
(select o.sys_name,o.day,o2.cc_cod e1 from org2 o2 inner join org o on o.cc_code
between 80000 and 90000 and o2.c_code = o.cc_code)
union
(select o.sys_name,o.day,o2.cc_cod e2 from org2 o2 inner join org o on o.cc_code
between 80000 and 90000 and o2.c_code = o.cc_code)
-- on (o.cc_code > 80000 and o.cc_code < 90000)
union
(select o.sys_name,o.day,o2.cc_cod e3 from org2 o2 inner join org o on o.cc_code
between 80000 and 90000 and o2.c_code = o.cc_code)
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----where org was first table,org2 was second table
(select o.sys_name,o.day,o2.cc_cod
between 80000 and 90000 and o2.c_code = o.cc_code)
union
(select o.sys_name,o.day,o2.cc_cod
between 80000 and 90000 and o2.c_code = o.cc_code)
-- on (o.cc_code > 80000 and o.cc_code < 90000)
union
(select o.sys_name,o.day,o2.cc_cod
between 80000 and 90000 and o2.c_code = o.cc_code)
--------------------------
ASKER
if i dont make it hard code can ? i need based on the `count` value to loop through the rc_code 1 , rc_code 2 until the `count` value end
then you need to write procedure...
Simply normalize your data.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Problem 2: Table 2 is not normalized.
E.g.
Open in new window
btw, don't use special characters and spaces in object names. This requires extensive use of object delimiters.