mysql

Retrieving records that has both tag T1 and T2

Hi all, I need an sql query that will retrieve all items that have both tags, not any of tags. I already have a query but returns all items that hove both tags, not expected result. Find detailed description below. Thanks! Table structure: ITEMS TABLE ------------ item_id item_name TAGS TABLE ---------- tag_id tag_name ITEMTAGS TABL...

Dynamic javacript slideshow...

I have a javascript slideshow that pre-loads images out of a mySQL database and then displays them one at a time in an image tag in the HTML document. Briefly, it accomplishes this by pre-loading images like many slideshow tutorials show on the web, but instead of using static images (i.e. images/image1.jpg etc.) it uses a dynamic image ...

What is the best way to implement versioning to a MYSQL database?

Hi, I have to produce a versioning system to store multiple versions of my articles in a database to allow the user to roll-back if required. My first thoughts are when the user wants to edit an article really I get the sql to no longer update but you insert their information back into the database. Currently the problem is i have an a...

SQL like statement problems

I am having problems executing a prepared statement via mysqli. First I was getting Command out of sync errors. I am storing the result and closing the connection, and I have stopped getting this error, so hopefully the problem has stopped. However, the error in my sql syntax error, which was working fine while the commands were not in...

Log query before executing it.

Hi, I've run into a problem where I run some query and the mysqld process starts using 100% CPU power, without ending. I want to pinpoint this query. The problem is that log/development.log contains only queries that have finished. Any idea? ...

fetching data from a prepared statement.

I have a function, which is to return an array of rows containg records from a database, selected based on a LIKE query. I want this query to be a prepared statement for security reasons. Apparently I can not use bound parameters and the query function as I am doing. I am unsure then, of how to keep me query as a prepared statement, and ...

Problem facing while inserting data into dynamically created column of table.

Hi all, I am dynamically adding column to table in db through code using alter table query. But i am facing problem wen i am trying to insert values in that column. it throws an exception column does not exists. And wen i clean and rebuild my project through netbeans it works fine. I am using java and mysql as databse . Is there any...

What is the best way to diagnose and profile MySQL in live production server?

What tools/methods do you recommend to diagnose and profile MySQL in live production server? My goal to test alternative ways of scaling up the system and see their influence on read/write timing, memory, CPU load, disk access etc. and to find bottlenecks. ...

Supplying password to wrapped-up MySQL

Greetings. I have written a little python script that calls MySQL in a subprocess. [Yes, I know that the right approach is to use MySQLdb, but compiling it under OS X Leopard is a pain, and likely more painful if I wanted to use the script on computers of different architectures.] The subprocess technique works, provided that I supply...

LEFT JOIN problem within a Stored Procedure

I've an odd problem: SELECT a.uid, b.*, c.liveId FROM a INNER JOIN b ON (a.uid=b.uid AND a.versionNo=b.versionNo) LEFT JOIN c ON (a.uid=c.uid) WHERE a.memberId=1; I call that from a query browser and it returns 3 rows. I call it from within a stored procedure and it gives 2 rows (the LEFT JOIN becomes ineffective). DELIMITER // ...

C#/mySQL Data Retrieval Problems over Network

I have a mySQL database running on a server on the local network. If I make a normal SELECT statement, I get 6000 results. The execution time in the mySQL query browser is 0.35s, but the data is received and shown in query browser after 9s. I have the same problem if I try to access the data through the .NET application. The query its...

Select all rows that correspond to a time

Hello, I have a script that sends out emails every minute. When it starts its loop, it queries the database for all entries that are equal to the current utc time. I would like to have it find all entries in the database that correspond to the current time down to the minute. So there is a 'time' column that stores the utc time: '2009-...

Using multiple COUNTs and SUMs in a single SQL statement

I have a tables called pages, page_views, page_items and page_votes. The latter three tables contain a page_id foreign key in order to keep a record of each individual view, item and vote that belongs to a page. When I query a page, I also want to retrieve COUNT page_views, COUNT page_items and SUM page_votes.vote. I have pasted a quer...

Reserve Autoincrement ID Within Transaction

Say I have two tables, users and groups each of which has an auto-incrementing primary key. Whenever a new user is created, I would like to create a group along with that user (at the same time/same transaction). However, the users need to know which group they belong to thus each user stores a group_id. In order to do this, I create ...

Best method for storing a list of user IDs

I'm working on a PHP/MySQL rating system right now. For the user to be able to rate the user has to log in. Each user has a unique "UID". There will be multiple rating instances on the website (one for every game, in my case) and I need an efficient way of storing a list of UIDs in a MySQL row (one MySQL row in the ratings table for each...

MySQL licensing and GPL

As far as I know, when I build a desktop/server app using any GPL code like MySQL I will have to release the source code of my software under the GPL. If I want to develop a web-app using MySQL, my code will link against the MySQL libraries. Must I release the sourcecode of my webapp in this situation to be in accordance with the GPL? ...

How do you encode an apostrophe so that it's searchable in mysql?

I don't think that was the most clear question, but an example should make it a little clearer. I have a table filled with movie names, some of which contain apostrophes. I have a search box which is used to find movies. If I perform searches via mov_title = '$search_keywords' it all works, but this method will not yield any resul...

Efficient MySQL table structure for rating system

This post is a follow-up of this answered question: Best method for storing a list of user IDs. I took cletus and Mehrdad Afshari's epic advice of using a normalized database approach. Are the following tables properly set up for proper optimization? I'm kind of new to MySQL efficiency, so I want to make sure this is effective. Also,...

Accessing a MySQL database from python.

I have been trying for the past several hours to find a working method of accessing a mysql database in python. The only thing that I've managed to get to compile and install is pyodbc but the necessary driver is not available for ppc leopard. I already know about this. UPDATE: I've gotten setuptools to install, but now MySQL-python ...

How do you make websites with Java?

This might be a really trivial question, but I've been writing Java programs at my school. But I just found out that I can create websites with Java as well. How can I do that? Any good books/tutorials for that? Also, I know about PHP, which is better for Web development? Also, when using PHP, MySQL comes into picture and while writing J...