Skip to content

Tag: mysql

MySQL remove zeros from decimal part if the number is whole

I have a sales table with price column as decimal(8, 2) and I’m running the query below to get the total price It’s working perfectly but my results are usually intergers so I end up with trailing zeros all the time. It’d be nice to just return the whole number if there is no decimal part An…

SQL – get the value of the related update by date

Say I have 2 tables Orders: And I have a table that contains updates of the dollar to pound values on various dates My goal is to query for the pound price, using the updated price for the time, so I get something like this How can I connect the 2 tables? Using equals won’t work, as Answer You could

MySQL Query Returns Different Results

I’m having a strange problem with the following query: Sometimes I get zero, one, two or three results. I should always get three results. What could be causing this? Answer As pointed out by Solarflare, GROUP_CONCAT() could produce your team string in a random order, e.g. ‘Van Williams & Dere…

How to convert SQL query in laravel query?

I know this question is not asked in a well manner way,so I am sorry,I have SQL query this one I want to convert it in PHP laravel query form so tried this query but I don’t know SQL and even I am not understanding how I convert it, can someone help just convert SQL query to laravel query? here