mysql

Find best matching row in MySQL (InnoDB)

I have the following test string engine/mail/key and a table which looks like this: +-------------+ | query | +-------------+ | engine | | engine/pdf | | engine/mail | +-------------+ I want to find the best matching row. Best match is specified by the most matching characters from the start of the string/row. I have con...

MySQL DB design help.

Hello All, Pardon the elementary question but my newness to the realm of database design leaves me in a bind quite often. I have a site that keeps growing with regard to families of information. In the beginning I had one sort of item I was describing and all was well. That item occupied one record and had 34 columns (a lot now that ...

How do I reverse or invert key values?

I'm working with a mysql group_concat function and I'm having some problems. I've just noticed that the array value really isn't a value but rather a part of my result which is not correct. I need to make the string the value so that I can reference it. Here is the portion of the SQL that I have: GROUP_CONCAT(t3.location, t2.content...

what syntax would i use to query the whole database?

I would like to select a row from 2 different tables that are relational. Would i simply put SELECT * FROM 'said database' WHERE my condition = 'mycondition' blah blah. Or is it some other syntactical method? Please help. :) All answers are greatly appreciated. ...

How to make sure there is no race condition in MySQL database when incrementing a field?

How to prevent a race condition in MySQL database when two connections want to update the same record? For example, connection 1 wants to increase "tries" counter. And the second connection wants to do the same. Both connections SELECT the "tries" count, increase the value and both UPDATE "tries" with the increased value. Suddenly "trie...

Updating previous status as dead when new update is inserted.

I have a simple insert query on my social network that allows the user to enter text in a text area and have it output on their profile page. They have the option to delete and it marks the status as dead,as intended, and erases the update. The problem is, if they just type in a new one, without deleting what is already there (which I wa...

php "football manager-lite" match engine

i am preparing to build my football manager php game but i am currently worried about how i am going to implement a realistic match engine. i have no experience whatsoever of creating game engines within php. the type of engine i am hoping to build is one which fetches a certain range of in-match phrases that commentators usually make i...

Anything Similar To WAMP?

Hello, I would like to know if anyone out there knows about any program similar to WAMP; all-in-one containing PHP, MySQL, Apach like WAMPServer? Thanks Edit: I am targeting Windows OS. ...

Help in displaying data on user page. I think ive gone on a tangent here.

I'm trying to display the data here in order of: Author Name Book Name Url NOTE: There are many results for each piece of data. Im not sure how they are stored in the array when they are fetched. The database schema is relational as you will see and connects these bits of information from different areas of the database. Im new t...

Calculating average age in Django

I need to find out average age of items (groupped by various criteria, but it does not seem to be the issue). However I fail to find how to effectively create aggregation over DateTimeField using Django (on top of MySQL). Pure Item.objects.all.aggregate(Avg('created')) seems to produce absolutely bogus values (eg. 20081988007238.133) an...

UUID performance in MySQL?

We're considering using UUID values as primary keys for our MySQL database. The data being inserted is generated from dozens, hundreds, or even thousands of remote computers and being inserted at a rate of 100-40,000 inserts per second, and we'll never do any updates. The database itself will typically get to around 50M records before w...

Convert blob to text in a mysql export

Hi! I'd have some blob data such as: 0x3333332c2044e963617269652c20356520e9746167650d0a53742d4c617572656e7420285175e9626563292048344e20334d390d0a that I'd like to convert to text because the new database has text field instead of blobs and now it makes trouble with some accentuated characters. Is there somekind of blob to string con...

unable to search using timestamp in mysql

I have created a timestamp field in mysql, where the date gets stored as 06/01/2010 07:55:40 Now if I try to search anything using a query like this : select StartTime from results where timestamp(StartTime) = "30/09/2009" it does not work. even I cannot use this : select * from results where StartTime between "06/01/20...

How can I "select *" from a table in mysql but omit certain columns?

I have table has id,name,age,surname,lastname,catgory,active instead of select name,age,surname,lastname,catgory from table how can I make something like this select * from table but not select id,active ...

How to re-sync the Mysql DB if Master and slave have different database incase of Mysql replication?

Mysql Server1 is running as MASTER. Mysql Server2 is running as SLAVE. Now DB replication is happening from MASTER to SLAVE. Server2 is removed from network and re-connet it back after 1 day. After this there is mismatch in database in master and slave. How to re-sync the DB again as after restoring DB taken from Master to Slave also ...

Is 20K reads going to make INSERTing into my table slow? How about a foreign key failure?

It's taking 10 - 11 seconds sometimes to INSERT into my table which has under a dozen records. I'm getting the following in my database's InnoDB status: 0.29 inserts/s, 0.03 updates/s, 0.09 deletes/s, 20365.73 reads/s. 20.37K reads/s Seems like a lot--do you agree? I'm not sure the 20K reads is all the same table, but it's quite poss...

How to get Id name with jquery and pass to php script?

Hello, I have been trying to get the id of a button(in this case a link) with jquery and send the id or class name to a php script so I can enter that id or class name in a sql query. I thought that this would be the easiest thing to do, but it has turned out to be the most difficult thing since nothing seems to work. I have on one pag...

Should I remove banned contents on my database?

Hi, I'm in front of decision on how to do with flagged data by the users. The banned data could be an image, a wiki, an user and something else need to be managed like a message board. I'd like to work with user stats in many cases, to find users with bad behaviour, users with many activity, users with best photos and so on with all I c...

Can table columns with a foreign key be null?

For example, I have a table which has several ID columns to other tables. I want a foreign key to force integrity only if I do put data in there. If I do an update at a later time to populate that column then it will still check the constraint (this is likely database server dependant, i'm using MySQL & InnoDB table type). I believe this...

Mysql 5.1 on Mac: query cache not working

Hi, I was wondering if someone could point me in the right direction. I have set up a local Mysql 5.1 sandbox on my Snow Leopard OSX machine, I have the Macports Mysql 5.1 installed and, by all appearances, functioning. It takes queries, the database is working, etc. The only strange thing is, the query cache isn't functioning. I have ...