I have been working on this for about two days now and cant seem to figure it out so I would love some help.
I have two tables:
mysql> select id, date, volume, symbol_id from control_quotedaily limit 5;
+-------+---- -------+----------+-----------+
| id | date | volume | symbol_id |
+-------+------------+----------+-----------+
| 13263 | 2017-11-02 | 7800191 | AXISBANK |
| 13264 | 2017-11-02 | 9303981 | SBIN |
| 13265 | 2017-11-02 | 8013536 | HDFCBANK |
| 13266 | 2017-11-03 | 9642624 | AXISBANK |
| 13267 | 2017-11-04 | 19642327 | AXISBANK |
+-------+------------+----------+-----------+
5 rows in set (0.00 sec)
14 rows in set (0.01 sec)
mysql> select * from control_oidaily
+-----------+------------+-------------+--------------+
| symbol_id | date | expiry_date | val_in_lakhs |
+-----------+------------+-------------+--------------+
| AXISBANK | 2017-11-02 | 2017-11-30 | 166881.8 |
| AXISBANK | 2017-11-02 | 2017-12-28 | 2676.84 |
| AXISBANK | 2017-11-02 | 2018-01-25 | 97.13 |
| HDFCBANK | 2017-11-02 | 2017-11-30 | 76351.11 |
| HDFCBANK | 2017-11-02 | 2017-12-28 | 1509.48 |
| HDFCBANK | 2017-11-02 | 2018-01-25 | 0 |
| SBIN | 2017-11-02 | 2017-11-30 | 88654.3 |
| SBIN | 2017-11-02 | 2017-12-28 | 1060.51 |
| SBIN | 2017-11-02 | 2018-01-25 | 0 |
| AXISBANK | 2017-11-03 | 2017-11-30 | 87640.06 |
+-----------+------------+-------------+--------------+
So for every quote in the control_quotedaily table this is what I want:
closest expiry_date for that quote from the control_oidaily table
I want the val_in_lakhs for that expiry_date.
Eg: For date 2017-11-02, the closest expiry is 2017-11-30 and I want the val_in_lakhs (76351.11) returned.
This is what I am trying:
select o.date, o.expiry_date as expiry_date, o.symbol_id, q.date, q.symbol_id, o.val_in_lakhs, q.tottrdval, q.volume, q.symbol_id
FROM control_oidaily o
JOIN ( select o.date, MIN(expiry_date) as expiry_date, symbol_id
FROM control_oidaily o
GROUP by o.date,o.symbol_id
ORDER BY o.date asc) as ed
ON ed.date = o.date
AND ed.symbol_id = o.symbol_id
AND ed.expiry_date = o.expiry_date
JOIN control_quotedaily q
ON q.date = ed.date
AND q.symbol_id = ed.symbol_id
This is the output I am expecting:
+-------+------------+----------+-----------+--------------+--------------+
| id | date | volume | symbol_id | expiry_date | val_in_lakhs |
+-------+------------+----------+-----------+--------------+--------------+
| 13263 | 2017-11-02 | 7800191 | AXISBANK | 2017-11-30 | 166881.8 |
| 13264 | 2017-11-02 | 9303981 | SBIN | 2017-11-30 | 88654.3 |
| 13265 | 2017-11-02 | 8013536 | HDFCBANK | 2017-11-30 | 76351.11 |
| 13266 | 2017-11-03 | 9642624 | AXISBANK | 2017-11-30 | 87640.06 |
+-------+------------+----------+-----------+--------------+--------------+
In a Derived Table, get the closest_expiry_date (minimum value of expiry_date), for a grouping of symbol_id and date, from control_oidaily table.
Join this with the control_quotedaily table on symbol_id and date, to get closest_expiry_date value for every row in the control_quotedaily table.
Now, use the same derived table again to join with control_oidaily table, matching up on date, expiry_date (with closest expiry date) and symbol_id to get val_in_lakhs.
You possibly want the following query:
SELECT q.id,
q.`date`,
q.volume,
q.symbol_id,
o1.expiry_date,
o1.val_in_lakhs
FROM control_quotedaily AS q
JOIN (SELECT o2.`date`,
o2.symbol_id
MIN(o2.expiry_date) as closest_expiry_date
FROM control_oidaily AS o2
GROUP by o2.`date`, o2.symbol_id
) AS dt
ON dt.`date` = q.`date`
AND dt.symbol_id = q.symbol_id
JOIN control_oidaily AS o1
ON dt.`date` = o1.`date`
AND dt.symbol_id = o1.symbol_id
AND dt.closest_expiry_date = o1.expiry_date
Related
I'm looking for a query to get monthly net sales I tried this far but I couldn't get what I want.
this is my Order Table
+----------+-----------+--------+------------+---------------+-------------+-----------+---------+---------+
| orderID | custID | userID | orderDate | paymentMethod | grossAmount | netAmount | cash | balance |
+----------+-----------+--------+------------+---------------+-------------+-----------+---------+---------+
| INV-0001 | CUST-0001 | U-001 | 2020-05-01 | Cash Pay | 525.00 | 525.00 | 550.00 | 25.00 |
| INV-0002 | CUST-0001 | U-001 | 2020-05-01 | Cash Pay | 240.00 | 240.00 | 250.00 | 10.00 |
| INV-0003 | CUST-0001 | U-001 | 2020-05-01 | Cash Pay | 220.00 | 220.00 | 250.00 | 30.00 |
| INV-0004 | CUST-0001 | U-001 | 2020-04-30 | Cash Pay | 895.00 | 895.00 | 1000.00 | 105.00 |
| INV-0005 | CUST-0001 | U-001 | 2020-04-30 | Cash Pay | 300.00 | 300.00 | 500.00 | 200.00 |
| INV-0006 | CUST-0001 | U-001 | 2020-04-30 | Cash Pay | 230.00 | 230.00 | 250.00 | 20.00 |
+----------+-----------+--------+------------+---------------+-------------+-----------+---------+---------+
This is my CustomerReturn Table
+-------+----------+------------+--------+------------+-----------+-----------+-------------+
| retID | orderID | itemCode | userID | retDate | returnQty | unitPrice | totalAmount |
+-------+----------+------------+--------+------------+-----------+-----------+-------------+
| 1 | INV-0001 | 1800232050 | U-001 | 2020-05-01 | 1.00 | 100.00 | 100.00 |
| 2 | INV-0002 | 1909873674 | U-001 | 2020-05-01 | 2.00 | 55.00 | 110.00 |
| 3 | INV-0004 | 1800232050 | U-001 | 2020-04-30 | 1.00 | 100.00 | 100.00 |
+-------+----------+------------+--------+------------+-----------+-----------+-------------+
the formula is (total of the monthly bill(Order.netAmount) - a total of monthly return (CustomerReturn.totalAmount))
in need to get net sales every year of every month.
select orderDate,sum(netAmount)-sum(totalAmount) from `Order` o,CustomerReturn r where o.orderID=r.orderID GROUP BY orderDate;
when I run this query it shows me this
+------------+---------------------------------+
| orderDate | sum(netAmount)-sum(totalAmount) |
+------------+---------------------------------+
| 2020-04-30 | 795.00 |
| 2020-05-01 | 555.00 |
+------------+---------------------------------+
but it should be Like this
+------------+---------------------------------+
| orderDate | sum(netAmount)-sum(totalAmount) |
+------------+---------------------------------+
| 2020-04-30 | 1425.00 |
| 2020-05-01 | 775.00 |
+------------+---------------------------------+
please help me. Thank you.!
Your query is good, it is fetching all records when there is a match on OrderId in the table CustomerReturn and doing the sums as you requested, however there are no returns for the order INV-0003, so this condition o.orderID=r.orderID is not valid when it comes to that record and it is ignoring that data. Doing a left join will fix the issue.
select
o.orderDate,
sum(o.netAmount)-sum(case when cr.totalAmount is null then 0 else cr.totalAmount end)
from
Orders o
left join
CustomerReturn cr
on
o.orderID = cr.orderID
group by
o.orderDate
A left join will cause cr.totalAmount to have null values in case there is no match for o.orderID=r.orderID then we use this part; case when cr.totalAmount is null then 0 else cr.totalAmount end to fix that null issue.
Because you are joining on dates that is why you are not getting correct answer, as order date and return date can have different month.
Better if you extract the month and then do sum as shown in below query, and here is the demo.
select
o.mm as month,
sum(total_net_amount - total_amount) as total
from
(
select
month(orderDate) as mm,
sum(netAmount) as total_net_amount
from Orders
group by
month(orderDate)
) o
join
(
select
month(retDate) as mm,
sum(totalAmount) as total_amount
from CustomerReturn
group by
month(retDate)
) cr
on o.mm = cr.mm
group by
o.mm
Output:
*--------------*
|month | total |
*--------------*
| 5 | 775 |
| 4 | 1325 |
*--------------*
Learn to use proper, explicit, standard, readable JOIN syntax. As pointed out in another answer, you want a LEFT JOIN. That said, the simpler way to write the logic is:
select o.orderDate,
sum(o.netAmount)- coalesce(sum(cr.totalAmount, 0)) as net_amount
from Orders o left join
CustomerReturn cr
on o.orderID = cr.orderID
group by o.orderDate;
Sample data:
db1.locationDetails table
| id | locationUID | locationName |
|----|-------------|--------------|
| 1 | L0001 | Site A |
| 2 | L0002 | Site B |
| 3 | L0003 | Site C |
| 3 | L0004 | Site D |
db2.HealthData table
| id | locationID | Date_Time | memUsage |
|----|-------------|------------------|----------|
| 1 | L0001 | 2018-09-10 11:43 | 35 |
| 2 | L0002 | 2018-09-10 08:22 | 39 |
| 3 | L0003 | 2018-09-10 14:44 | 43 |
| 4 | L0004 | 2018-09-10 16:01 | 72 |
| 5 | L0001 | 2018-09-12 01:26 | 50 |
| 6 | L0002 | 2018-09-12 03:15 | 32 |
I have a query:
SELECT DISTINCT db1.locationDetails.locationUID,
db1.locationDetails.locationName,
MAX(db2.HealthData.Date_Time),
db2.HealthData.memUsage,
IF(DATE(db2.HealthData.Date_Time) = '2018-09-12', "ON", "OFF") AS Status
FROM db1.locationDetails
LEFT JOIN db2.HealthData
ON db1.locationDetails.locationUID = db2.HealthData.locationID
GROUP BY db1.locationDetails.locationUID
Based on my understanding, the 'Status' column will show "ON" if the Date is equals to 2018-09-12 but somehow it always returns "OFF" regardless of whether the value in the Date_Time column is equal to the Date value specified in the query.
Can anyone tell me what is wrong here? Thanks in advance.
Expected output:
| locationUID | locationName | Date_Time | memUsage | Status |
|-------------|--------------|-----------------|----------|--------|
| L0001 | Site A |2018-09-12 01:26 | 50 | ON |
| L0002 | Site B |2018-09-12 03:15 | 32 | ON |
| L0003 | Site C |2018-09-10 14:44 | 43 | OFF |
| L0004 | Site D |2018-09-10 16:01 | 72 | OFF |
Use subquery to get your desired result:
select x.locationuid,x.locationname,maxitme, memusage, case when date(maxtime)='2018-09-12' then 'ON' else 'OFF' end as status
from db1.locationDetails x
inner join
(select a.locationuid,maxtime,memusage
from
(SELECT locationUID,MAX(Date_Time) as maxtime FROM db2.HealthData group by locationUID)a
inner join db2.HealthData b on a.locationuid=b.locationuid)y
on x.locationuid=y.locationuid
add Group by db1.locationDetails.locationUID,db2.HealthData.id
SELECT DISTINCT db1.locationDetails.locationUID,
db1.locationDetails.locationName,
MAX(db2.HealthData.Date_Time),
db2.HealthData.memUsage,
IF(DATE(db2.HealthData.Date_Time) = '2018-09-12', "ON", "OFF") AS Status
FROM db1.locationDetails
LEFT JOIN db2.HealthData
ON db1.locationDetails.locationUID = db2.HealthData.locationID
GROUP BY db1.locationDetails.locationUID,db2.HealthData.id
In a sample project i wanted to display data in such a way that based on dates the records for same student comes in additional columns.
mysql> desc sch_student;
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| s_first_name | varchar(128) |
| s_last_name | varchar(128) |
| rollcode | int(8) |
| regnum | int(8) |
| in_time | datetime |
| out_time | datetime |
| total_time | int(8) |
+----------------+--------------+
for below query i am getting sample output like below , my expected output is something i am unable to get. I tried Sample join but it didn't work.
mysql> select * from sch_student;
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+
| s_first_name | s_last_name | rollcode | regnum | in_time | out_time | total_time |
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+
| Suzan | Matsuo | 8900 | 2897 | 2017-12-02 22:30:11 | 2017-12-02 22:30:11 | 00:17:00 |
| Scottie | Ogletree | 5624 | 5627 | 2017-12-02 16:40:01 | 2017-12-02 16:40:05 | 00:26:04 |
| Cynthia | Zimmerman | 3107 | 6348 | 2017-12-02 16:35:01 | 2017-12-02 16:35:01 | 00:59:89 |
| Ricardo | Shurtliff | 3072 | 261 | 2017-12-02 15:33:01 | 2017-12-02 15:33:01 | 00:16:55 |
| Elizabeth | Milligan | 4722 | 3233 | 2017-12-02 15:06:00 | 2017-12-02 15:10:33 | 00:14:33 |
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+
Expected output is something like below
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+--------------+-----------+---------------------+---------------------+----------------+
| s_first_name | s_last_name | Today's Meeting | Day Before Yesterday's Meeting |
| | rollcode | regnum | in_time | out_time | total_time | rollcode | regnum | in_time | out_time | total_time |
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+--------------+-----------+---------------------+---------------------+----------------+
| Suzan | Matsuo | 8900 | 2897 | 2017-12-02 22:30:11 | 2017-12-02 22:30:11 | 00:17:00 | 8900 | 2897 | 2017-11-30 12:30:11 | 2017-11-30 12:50:11 | 00:17:00 |
| Scottie | Ogletree | 5624 | 5627 | 2017-12-02 16:40:01 | 2017-12-02 16:40:05 | 00:26:04 | 5624 | 5627 | 2017-11-30 18:40:01 | 2017-11-30 19:33:05 | 00:26:04 |
| Cynthia | Zimmerman | 3107 | 6348 | 2017-12-02 16:35:01 | 2017-12-02 16:35:01 | 00:59:89 | 3107 | 6348 | 2017-11-30 13:35:01 | 2017-11-30 14:15:01 | 00:59:89 |
| Ricardo | Shurtliff | 3072 | 261 | 2017-12-02 15:33:01 | 2017-12-02 15:33:01 | 00:16:55 | 3072 | 261 | 2017-11-30 19:33:01 | 2017-11-30 20:33:01 | 00:16:55 |
| Elizabeth | Milligan | 4722 | 3233 | 2017-12-02 15:06:00 | 2017-12-02 15:10:33 | 00:14:33 | 4722 | 3233 | 2017-11-30 18:06:00 | 2017-11-30 19:10:33 | 00:14:33 |
+-------------------+---------------+--------------+-----------+---------------------+---------------------+----------------+--------------+-----------+---------------------+---------------------+----------------+
I tried below join and it's not returning expected output. Is it possible to display conditional column from table?
select * from
(
(select s_first_name,s_last_name,rollcode,regnum,in_time from sch_student where sch_student.in_time BETWEEN CURDATE()- INTERVAL 1 DAY AND CURDATE() ) As TD,
(select s_first_name,s_last_name,rollcode,regnum,in_time from sch_student where sch_student.in_time BETWEEN CURDATE()- INTERVAL 3 DAY AND CURDATE() ) As DBYS
) ;
I think this is what you need. I haven't tested it. Basically the query gets todays data LEFT joins to the day before yesterday's data. I assumed regnum and rollcode makes your primary key. Change if that isnt the case.
SELECT TD.* , DBYS.*
FROM (
SELECT s_first_name
,s_last_name
,rollcode
,regnum
,in_time
FROM sch_student
WHERE sch_student.in_time BETWEEN CURDATE() - INTERVAL 1 DAY
AND CURDATE()) AS TD
LEFT JOIN (
SELECT s_first_name
,s_last_name
,rollcode
,regnum
,in_time
FROM sch_student
WHERE sch_student.in_time BETWEEN CURDATE() - INTERVAL 3 DAY
AND CURDATE() - INTERVAL 2 DAY) AS DBYS
ON (TD.regnum = DBYS.regnum AND
TD.rollcode = DBYS.rollcode);
If you want to get info for today's meeting and the "day-before-yesterday's" meeting, try using a LEFT JOIN instead:
SELECT s_first_name, s_last_name, rollcode, regnum, in_time
FROM sch_student AS sch_today
LEFT JOIN sch_student AS sch_daybeforeyesterday ON
sch_today.<PK_FIELD> = sch_daybeforeyesterday.<PK_FIELD> AND
sch_daybeforeyesterday.in_time BETWEEN CURDATE()- INTERVAL 3 DAY AND CURDATE() - INTERVAL 2 DAY
WHERE sch_student.in_time BETWEEN CURDATE()- INTERVAL 1 DAY AND CURDATE()
This will give you all rows with "in_time" within the last 0-24 hours. For each of those rows, it will return any corresponding rows with "in_time" within the 48-72 hours.
invoice table
SELECT id, fname, gtotal, `date` FROM invoice WHERE id = 1;
| id | fname | gtotal | date |
|----|---------|--------|-----------------------|
| 1 | Brandon | 860 | May, 11 2016 00:00:00 |
invoice_contents table,
SELECT * FROM invoice_contents WHERE invoice_id = 1;
| id | invoice_id | item | price | quantity | discount | total |
|----|------------|------------|-------|----------|----------|-------|
| 1 | 1 | Dextrose | 10 | 10 | 5 | 95 |
| 2 | 1 | Nescaine | 20 | 30 | 10 | 540 |
| 3 | 1 | Anticavity | 30 | 10 | 25 | 225 |
This JOIN query
SELECT invoice.id, invoice.fname, invoice_contents.item,
invoice_contents.price, invoice_contents.quantit,
invoice_contents.discount, invoice_contents.total,
invoice.gtotal
FROM invoice_contents
INNER JOIN invoice ON invoice_contents.invoice_id=1 AND invoice.id=1;
gives this result.
| id | fname | item | price | quantity | discount | total | gtotal |
|----|---------|------------|-------|----------|----------|-------|--------|
| 1 | Brandon | Dextrose | 10 | 10 | 5 | 95 | 860 |
| 1 | Brandon | Nescaine | 20 | 30 | 10 | 540 | 860 |
| 1 | Brandon | Anticavity | 30 | 10 | 25 | 225 | 860 |
I need this result.
| id | fname | item | price | quantity | discount | total | gtotal |
|----|---------|------------|-------|----------|----------|-------|--------|
| 1 | Brandon | Dextrose | 10 | 10 | 5 | 95 | 860 |
| | | Nescaine | 20 | 30 | 10 | 540 | |
| | | Anticavity | 30 | 10 | 25 | 225 | |
I am just a beginner in MySQL. I have been trying from this morning to get this kind of output by experimenting on different combinations please help me out.
#Rex, Your select is correct. You should make desired output using some script e.g. PHP.
try this in SQL:
in this Query i save everytime fname in a variable is not equal and at the next row i compare it and return a empty string is it equal. and the same for gtotal.
the cross join is only to initialize the variables.
in this case it is important that the rows are order by fname to ensure that the same name is behind each other
SELECT
invoice.id,
IF(#last_fname = invoice.fname, '', (#last_fname:=invoice.fname)) as fname,
invoice_contents.item,
invoice_contents.price,
invoice_contents.quantity,
invoice_contents.discount,
IF(#last_gtotal = invoice.gtotal, '', (#last_gtotal:=invoice.gtotal)) as gtotal
FROM invoice_contents
INNER JOIN invoice ON invoice_contents.invoice_id=1 AND invoice.id=1
CROSS JOIN ( select #last_fname := '' , #last_gtotal := '' ) AS parameter
ORDER BY invoice.fname;
Sample
MariaDB [bb]> SELECT
-> invoice.id,
-> IF(#last_fname = invoice.fname, '', (#last_fname:=invoice.fname)) AS fname,
-> invoice_contents.item,
-> invoice_contents.price,
-> invoice_contents.quantity,
-> invoice_contents.discount,
-> IF(#last_gtotal = invoice.gtotal, '', (#last_gtotal:=invoice.gtotal)) AS gtotal
-> FROM invoice_contents
-> INNER JOIN invoice ON invoice_contents.invoice_id=1 AND invoice.id=1
-> CROSS JOIN ( SELECT #last_fname:='' , #last_gtotal:='' ) AS parameter
-> ORDER BY invoice.fname;
+----+---------+------------+-------+----------+----------+--------+
| id | fname | item | price | quantity | discount | gtotal |
+----+---------+------------+-------+----------+----------+--------+
| 1 | Brandon | Dextrose | 10.00 | 10 | 5.00 | 860.00 |
| 1 | | Nescaine | 20.00 | 30 | 10.00 | |
| 1 | | Anticavity | 30.00 | 10 | 25.00 | |
+----+---------+------------+-------+----------+----------+--------+
3 rows in set, 1 warning (0.00 sec)
MariaDB [bb]>
my tables and their layout:
mysql> select * FROM xt_shipping_zones;
+---------+-------------+---------------------------------------------------------------------------+
| zone_id | zone_name | zone_countries |
+---------+-------------+---------------------------------------------------------------------------+
| 5 | ZONE1 | AT,BE,BG,DK,FI,FR,GR,IE,IT,LV,LT,LU,MC,NL,PL,PT,RO,SM,SE,SK,SI,ES,HU,GB |
| 6 | Deutschland | DE |
| 8 | ZONE2Brutto | AD,NO,VA |
| 9 | ZONE2NETTO | CH,LI |
+---------+-------------+---------------------------------------------------------------------------+
mysql> select * FROM xt_shipping_cost WHERE shipping_geo_zone = 99995 LIMIT 5;
+------------------+-------------+-------------------+-----------------------+--------------------------+------------------------+----------------+------------------+
| shipping_cost_id | shipping_id | shipping_geo_zone | shipping_country_code | shipping_type_value_from | shipping_type_value_to | shipping_price | shipping_allowed |
+------------------+-------------+-------------------+-----------------------+--------------------------+------------------------+----------------+------------------+
| 269 | 34 | 99995 | | 0.31 | 17.99 | 17.0000 | 1 |
| 270 | 34 | 99995 | | 17.99 | 35.99 | 34.0000 | 1 |
| 271 | 34 | 99995 | | 35.99 | 53.99 | 51.0000 | 1 |
| 272 | 34 | 99995 | | 53.99 | 71.99 | 68.0000 | 1 |
| 273 | 34 | 99995 | | 71.99 | 89.99 | 85.0000 | 1 |
+------------------+-------------+-------------------+-----------------------+--------------------------+------------------------+----------------+------------------+
mysql> SELECT * FROM geoip WHERE 92569600 BETWEEN start AND end;
+----------+----------+---------+-----+
| start | end | country | id |
+----------+----------+---------+-----+
| 92569600 | 92585983 | AT | 895 |
+----------+----------+---------+-----+
My Query:
SELECT
xt_shipping_cost.shipping_type_value_from,
xt_shipping_cost.shipping_type_value_to,
xt_shipping_cost.shipping_price,
geoip.country
FROM xt_shipping_cost
INNER JOIN xt_shipping_zones
ON xt_shipping_cost.shipping_geo_zone = xt_shipping_zones.zone_id + 99990
INNER JOIN geoip
ON geoip.country REGEXP xt_shipping_zones.zone_countries
WHERE 34664448 BETWEEN geoip.start AND geoip.end
My Problem:
Query is working if there is only ONE entry in xt_shipping_zones.zone_countries like DE. If there are multiple (with comma seperated entries) i cant get a match on that row.
Doing it manually:
mysql> SELECT * FROM `xt_shipping_zones` WHERE `zone_countries` REGEXP 'AT';
+---------+-----------+---------------------------------------------------------------------------+
| zone_id | zone_name | zone_countries |
+---------+-----------+---------------------------------------------------------------------------+
| 5 | ZONE1 | AT,BE,BG,DK,FI,FR,GR,IE,IT,LV,LT,LU,MC,NL,PL,PT,RO,SM,SE,SK,SI,ES,HU,GB |
+---------+-----------+---------------------------------------------------------------------------+
SQLFiddle: http://sqlfiddle.com/#!9/68f8d0/1
I hope i didn't failed to much to make my problem clear.
Thank you
I think you can use find_in_set()
SELECT
xt_shipping_cost.shipping_type_value_from,
xt_shipping_cost.shipping_type_value_to,
xt_shipping_cost.shipping_price,
geoip.country
FROM xt_shipping_cost
INNER JOIN xt_shipping_zones
ON xt_shipping_cost.shipping_geo_zone = xt_shipping_zones.zone_id + 99990
INNER JOIN geoip
ON find_in_set(geoip.country, xt_shipping_zones.zone_countries)
WHERE 34664448 BETWEEN geoip.start AND geoip.end
It is no good idea to store the values as csv. That is very bad database design.