mysql

How to create an XML file from MySQL Data queries?

Hello I would like to know a way to create an XML file using MySQL queries only. without using any scripting language at all. Are there any books, tutorials on this topic ? UPDATE: I would like to clear it out that I want to use sql queries which would forward XML data to a php Script. ...

How can i install mysql workbench in fedora 11.

I download and try to install the rpm package for fedora 10, i also try compiled from source and finally ry to rebuild de rpm pakage from src.rpm package .. and nothing work.. does anyone know how can i install mysql workbench in fedora 11 ? Thanks. ...

Keyword search, multiple tables, PHP and Mysql, Which Join to use?

Hi I have 3 tables event, location, event_location. Event can have multiple locations. Location table has lattitude, longitude, hasGeocode fields. so for keywords "hello world" a simple query to Event table becomes Select * from event where keywords like '%hello%' OR keywords like '%world%' but if if the user has entered their loc...

Looking for MySQL optimization and fine-tuning tips

Howdy peeps. I hope you can help me with this one. I got a twitter service ( http://foller.me ) which is about to be updated to public beta 2, but I don't want to do this until I could give the pages out in at least 2 or 3 seconds. The current version is simple enough, but the dev version I'm working on is quite complex. It's all about...

Efficiently querying a 15,000,000 rows table in MySQL

Consider the following database tables: Table "messages" with 13,000,000 rows (one row per message). Table "users" with 3,000,000 rows (one row per user). The following query is used to fetch a bunch of messages and the corresponding users: SELECT messages.id, messages.message, users.id, users.username FROM messages INNER JOIN users...

How to minimize the load in queries that need grouping with different invervals?

I'm looking for a best practice advice how to speed up queries and at the same time to minimize the overhead needed to invoke date/mktime functions. To trivialize the problem I'm dealing with the following table layout: CREATE TABLE my_table( id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, important_data INTEGER, date INTEGER);...

simple preg_replace() that I can't get working (i suck at regex)

$count_sql = preg_replace("/SELECT(.+?)FROM/", "SELECT COUNT(*) FROM", $sql); It's probably pretty obvious what I'm trying to do, but I am terrible with regex. I need to replace anything between SELECT and FROM with COUNT(*). Tried using (.+), (.+?), (.*), and (.*?). ...

PHP/MYSQL AJAX Chat

Looking for an open source php/mysql ajax chat room (not 1-to-1 private chat). What would you guys recommend? I am going to need to make hundreds of instances of the chat room (eg. each user group has their own exclusive chat room) ...

Hibernate: Sorting by a field from a linked table if foreign key is null

Lets say I have two tables - "Cat" and "Cat owner" that are linked with many-to-one like this: <class name="com.example.Cat" table="cat"> ... <many-to-one name="owner" class="com.example.CatOwner" column="owner_id" not-null="false" insert="true" update="true" cascade="none" lazy="false"/> </class> Now I w...

Choice of MySQL table type for non-critical webapp data (MyISAM vs. InnoDB)

Consider this scenario with the following assumptions: The database is used for a non-critical webapp. Query speed is of vital importance. The read/write patterns are roughly >95 % reads and <5 % writes. The database is backuped up daily using mysqldump. The is no need for transactions or advanced crash recovery. If the database crash...

Outer Cross Join?

I'm trying to avoid using queries in while loops. Therefore I've come to the conclusion that I should use a cross join. Take this example: SELECT * FROM products CROSS JOIN images USING (imgId) CROSS JOIN productcolors ON colorsId = colorId WHERE productId = 1 should return two rows (table structure below): imgId | productId | colo...

Transfering MySQL Records from Database to Database

I have two databases: Transactions and Customer List I want to populate the customer list database with the customer information that is in the transactions database. I do not wish to transfer ALL of the information from the transactions database because the Customer List database has a different structure. How can I transfer these r...

Why doesn't my MySQL query work?

Why doesn't my MySQL query work? Query: DELETE FROM jos_community_awards a LEFT JOIN jos_community_users u ON a.userId = u.userid WHERE a.points > u.points; Error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that >corresponds to your MySQL server version for the right syntax to use near 'a LEF...

Alternative to MySQL CASE/WHEN?

I'm trying to select some integer values in MySQL. Several of the values are zero, which I want to grab as an empty string, and grab the integer values when available. So I have something like this: SELECT CASE field WHEN 0 THEN '' ELSE field, [repeat for other fields] Is there any way to shorten this in the SQL query? Does MySQL sup...

Counting word occurrences in a table

Hi, I have a table with a varchar(255) field. I want to get (via a query, function, or SP) the number of occurences of each word in a group of rows from this table. If there are 2 rows with these fields: "I like to eat bananas" "I don't like to eat like a monkey" I want to get word | count() --------------- like 3 ...

How do I connect webapp VB/LINQ to a MySQL database server on a Linux

I have a programmer who is using VB and LINQ; and I have a MySQL database that is running on a linux server. My programmer tells me that: he cannot connect to the MySQL database via LINQ if he was able to connect then it would require all sorts of rewriting I don't know anything about LINQ but I thought it was an ORM. As such, any D...

Insert one row for each key

Let's say I have two tables lnglngdef: lngId | lngName 1 Korean 2 Spanish lngnottranslated: lngId | engDef 1 Hello 2 Hello 1 Hi 2 Hi Now I want to insert a new "engDef" with the value 'Welcome' in the lngnottranslated for each entry in the lnglngdef table. In this case that's two new rows in the ln...

MySQL 5: Does it matter what order my GROUP BY fields are in?

Peeps, I have a few aggregate/calculated fields in my MySQL query. My GROUP BY clause is dynamically generated, depending on what options a user selects in a web form. Curious if the order of fields listed in the GROUP BY clause can have any impact on the calculations (things like SUMs, AVERAGEs, etc) Thanks! ...

MySQL Quick Bulk Inserts

We're developing a "Search Reporting" feature for a client. One of the requirements is that they can view a particular result and see which search terms lead to it. Our search_results table is simply a mapping of searches.id to results.id. So we need to do a bulk insert into this table and need to know the fastest way to do this withou...

MySQL get the date n days ago as a timestamp

In MySQL, how would I get a timestamp from, say 30 days ago? Something like: select now() - 30 The result should return a timestamp. ...