Viewing previous Queries in PHPMyAdmin

Viewing previous Queries in PHPMyAdmin

If you’re busy in PHPMyAdmin and you do alot of repeat queries, or you just come back to a query now and again, you might find it useful to have a record of those queries.  Whether it’s just saving you time retyping something, or if you’re switching back and forth between windows and accidentally close your query window, having a record is always good.  There are two useful things you can do.  The first is...

Read More

Dates & Datetimes when reading from MSSQL in PHP

Dates & Datetimes when reading from MSSQL in PHP

So it gets me every time I try to deal with dates in a query result when I’m getting rows from a MSSQL database in PHP. Normally I work with MySQL when I’m programming in PHP, but I have a hybrid application where .Net is used on the front end, and I do a bunch of back end things using PHP scripts. So here’s the issue. MSSQL doesn’t store things the same way MySQL does. MySQL seems to treat everything like a string. ...

Read More

The MySQL now() function in MSSQL

If I want to insert the current time into a field when doing an insert in MySQL I usually use the NOW() function. It’s built right into the query string and makes sure you get the time of insert. In MSSQL though you have to change things to getDate(). If you have a date field, it will adapt to your type, but you can also specify a format of the date as the parameter.

Read More

Selecting a running position of the returned row in MSSQL

For some reason this concept is hard to summarize in one line. Basically we’re looking to return how many rows are in the table before the row returned in the result. Sort of like what position the rows is in line. If we have a table like this: Row: 1,2,3 Row: 2,4,5 Row: 3,6,7 And we want to find out the position of row 2, then it’s fairly simple because the primary key will tell us what order it is. However, if you delete row 1,...

Read More

MySQL Update Row if Key Exists

Many times you have to do a query before you do a write action to a database because you have to see whether or not a row exists for the data you want to put in. If it does exist, you’d then do another query that was an update, otherwise you’d have to do an insert. Well if you want a quicker way, and you don’t need to use operators like “Update `column`+1″, then “REPLACE INTO” is the function for you. ...

Read More

MySQL Limiting Left Joins

Sometimes it’s nice to just use a left join to see if a column exists. That’s what left joins are for. Your base query will still return rows even if there are no rows in the joined table(s). However, what if there is a one to many relationship between the base table and the joined table, that is to say that for any row in the base table there could be any number of rows in the joined table. If you have more than one row in the...

Read More