ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

MYSQL CASE function using jsstore #152

Closed akhilponnala closed 4 years ago

akhilponnala commented 4 years ago

Hi, How can we implement MYSQL CASE function using jsstore. For example, SELECT CustomerName, City, Country,PhoneNumber, (CASE WHEN PhoneNumber IS NULL THEN '' ELSE PhoneNumber END) AS phone FROM Customers as c inner join Product as d on d.product_id=c.make inner join Product as d1 on d1.product_id=c.model GROUP BY phone ORDER BY (CASE WHEN City IS NULL THEN Country ELSE City END); Please help in implementation of above queries using jsstore. Thank you.

ujjwalguptaofficial commented 4 years ago

Do you want case for order query too ?

akhilponnala commented 4 years ago

yes

ujjwalguptaofficial commented 4 years ago

@akhilponnala - this feature is added in new version - 2.6.2. Take a look at doc - https://jsstore.net/tutorial/case/

Let me know if you have any questions.

Thanks

akhilponnala commented 4 years ago

Hi @ujjwalguptaofficial , Thank you for your support. I will try it and will let you know if any questions.

akhilponnala commented 4 years ago

Hi @ujjwalguptaofficial

Can we use 'Case' funtionality with group by clause. Can we apply then value from results dynamically. For example : select count(*) as s_count,d3.des as des1,(CASE d.des WHEN 'Other' THEN e.v_other ELSE d.des END) as making ,(CASE d1.des WHEN 'Other' THEN e.v_other ELSE d1.des END) as desc ,(CASE d.des WHEN 'Other' THEN e.v_other ELSE d.des END) as maker ,(CASE d1.des WHEN 'Other' THEN e.v_other ELSE d1.des END) as module ,sign.opId as oper_id from val as e inner join drop as d on d.drop_id=e.v_make inner join drop as d1 on d1.drop_id=e.v_model inner join sign as s on s.sig_id=e.sig_id inner join drop as d3 on d3.drop_id=s.oper_id group by making, module,oper_id order by oper_id Please help us on implementing above. Thank you.

ujjwalguptaofficial commented 4 years ago

Hi @akhilponnala

I have added more functionality to case query in v - 3.7.0. Now you can use case with order by, group by & in different way similar to MYSQL. Please read doc - https://jsstore.net/tutorial/case/ .

For any query please post here. Thanks.