Tag Archives: MySQL

MySQL related content

UPDATE: Keep order of rows while using WHERE IN () – MySQL

I was just solving issue, where I needed to keep an order of items returned from the MySQL database listen in the WHERE IN clause.
Original query:

SELECT * FROM table WHERE id IN (1,5,8,73,5,4,88)

This will return rows ordered by its primary key (in my case column id). Here is updated query, which will keep order of items listed in WHERE IN clause:

SELECT * FROM table WHERE id IN (1,5,8,73,5,4,88) ORDER BY FIELD(id,1,5,8,73,5,4,88)

Please note first item in brackets behind ORDER BY – there should be set same column, which was used at WHERE IN clause.

UPDATE: There was missing function called FIELD after ORDER BY – code is fixed now.

Google Maps API & PHP+MySQL – working with radius and distance

I needed to find out how to work with Google Geo API in my last project and especially with calculating a radius and distance between two geo points. Another goal was to get a latitude and longtitude from the address typed in the register form (in the background). Finally it was quiet easy. Here is the solution: Continue reading Google Maps API & PHP+MySQL – working with radius and distance

MySQL visual database design

I was looking for some nice freeware visual mysql database designer couple of weeks ago. I found two of them: DBDesigner 4 and MySQL Workbench. I must say, that both programs are really very similar, I mean from the view of the UI and menus structure. I gave a little user testing to both of them and designing database using these tools is very easy and fast… Continue reading MySQL visual database design