mysql

Multiple field report, with custom counts in MySql

Hey all, I am using a system I didn't create. The system has 3 main tables: users, courses, and usergroups. I am using an extra table called coursehits. It's a MySQL DB, 5.0. There aren't any relationships in the DB, so users are assigned to courses by simply adding an entry to usergroups (course_id and user_id) from the courses and u...

Trying to use MySQL protocol support and SphinxQL

But unluckily it seems I can't get the layer to work, all I see are my local mysql databases, what am I doing wrong? of course I'm connecting to the correct port. It seems that I connect to the default mysql server even if I give a non existant port ...

Select per month

I've got the following table: purchases(id, item, user, price, time); The time field is a timestamp. I need a query that would return one row per month and that row would contain the sum of price for each item in that month. ...

Wordpress post loop have posts fatal error?

I made a custom post loop query based on data from another plugin. I get this error: Fatal error: Call to a member function have_posts() on a non-object Here is the code I have made: ...

How to get created stored procedures in last 2 weeks?

Is there a way I can detect when was a stored procedure created/modified, so I can get a list of what has been altered in the last 2 weeks? ...

Best practice to handel ajax jquery database queries?

Hi, I have a "little" problem because I dont know whats the best way to handle ajax jquery databeas request? So far I've done it this way: For ever (single) database request I created a new .php file like: newbill.php newcosumer.php listallbills.php updatecostumer.php ..and so on and pull the data via: $.ajax({ type: "POST", u...

MySQL C++ Connector: undefined reference to `get_driver_instance'

Hey, I've been trying to get the MySQL connector working I've installed both the connector and the mysql client library but I am still getting this error: obj/Database.obj: In function `Database::connect()': /home/xeross/alpine/src/server/Database.cpp:13: undefined reference to `get_driver_instance' collect2: ld returned 1 exit status ...

How do I find the row where a certain value is between 2 others?

So, I have a mysql table that looks roughly like this, where the first 2 columns contain ranges. 1 , 5 , Value1 6 , 14 , Value2 14 , 18 , Value3 How can I query to find which row a certain value falls between (ie, if I have 9, it returns Value2; if I have 2, it returns Value1). This table is about 10mb big, so the more efficient, the...

Is there a way to extract submatches from a regular expression in MySQL?

I am aware of the existence of the RLIKE and REGEX operators, but it seems like they cannot be used for that. Is there a function or an operator that would help me achieve splitting a text field and selecting it as two or more separate fields: SELECT $1 as `field_a`, $2 as `field_b` FROM `table` WHERE `field` RLIKE '^(.+):(.+)$'; I a...

How to set and ending date value based on begining date with mySQL

I have a table with two fields, date_start & date_end, both are date fields. date_start currently is populated with various dates. I need to set date_end to 6/30 of the following year. So if date_start = 2009-03-15 then date_end = 2010-06-30 if date_start = 2010-03-15 then date_end = 2011-06-30 if date_start = 2010-07-01 then date_e...

Which best fits my needs: MongoDB, CouchDB, or MySQL. Criteria defined in question.

Our website needs a content management type system. For example, admins want to create promotion pages on the fly. They'll supply some text and images for the page and the url that the page needs to be on. We need a data store for this. The criteria for the data store are simple and defined below. I am not familiar with CouchDB or M...

Xampp / Lampp changing database dir (No datadir)

Hello, I want to use same database dir on my ubuntu installation as of windows 7, I read a lot on net which guided to change datadir of my.cnf but there is no datadir in my /opt/lampp/etc/my.cnf # Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 64M) where MySQL plays # an important part,...

Runtime "symbol lookup error" when accessing libmysqlclient.so functionality in C

Context: I am not certain whether this is my problem or the problem of the server this is running on. I am trying to compile and run a small utility, to become a cron job, that uses the mysql libraries. The program compiles successfully with the following command, no errors or warnings: gcc my_program.c -o my_program -I /usr/include/mys...

How to create complex Zend_Form to emulate iTunes Smart Playlist

Hi all, I'm developing an app which runs complex, configurable searches over multiple database tables, and displays the results. I have identified a number of different types of search I'd like to run, and have hard-coded the SQL queries to get the correct results. Each part of the queries have been abstracted, so building a query is as...

Stored procedure Auth

Hi, I'd like to authenticate users with the help of stored procedures. Here's what i've got so far... DELIMITER | CREATE PROCEDURE authenticateUser ( IN uname VARCHAR(64), IN passphrase VARCHAR(32) ) BEGIN SELECT u.id FROM users AS u WHERE u.email = uname AND u.pass = passphrase AND u.active = 1; END Now I'd like to add another fea...

Why does adding "left" to my join make the MySQL query hang?

This query executes in a fraction of a second: SELECT customers.customers_id, customers_firstname, customers_lastname, customers.customers_email_address, max(date_purchased) FROM customers join orders on customers.customers_id = orders.customers_id group by customers.customers_id; If I change the join to a left join, it seems to han...

How to bulk insert data to mysql with python

Currently i'm using Alchemy as a ORM, and I look for a way to speed up my insert operation, I have bundle of XML files to import for name in names: p=Product() p.name="xxx" session.commit() i use above code to insert my data paser from batch xml file to mysql,it's very slow also i tried to for name in names: p=Produc...

sum of a column (which is itself a sum) in mysql?

Basically, I have the following query: SELECT sr.name AS salesrepname, ct.name AS customertypename, c.name AS customername, c.code, p.description AS productname, p.unitofmeasure, SUM(col.vatableprice) AS totalsales, SUM(col.vatprice) AS vat, SUM(col.quantity) AS totalitems, SUM(col.quantity * col.costprice) AS totalsalecost, SUM(col...

MySQL: Join two tables, select one row at random.

First off, I created a screen cast, in order to explain what I have and what I'm attempting to create. Much easier to understand. Please view the screen cast here: http://www.youtube.com/v/lZf3S3EGHDw?fs=1&hl=en_US&rel=0&hd=1 Tables: CREATE TABLE `locations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(45) D...

Update dynamic input to mysql via php

I have dynamic form like below. <form action="edit.php" method="post"> <tr> <th scope="row" class="specalt">Product A</th> <td class="alt"><input class="input2" type="text" name="s_8" value="100" /></td> <td class="alt"><input class="input2" type="text" name="m_8" value="100" /></td> <input type='hidden' name='id_8' valu...