mysql

Lots of 'If statement', or a redundant mysql query?

Hey all, $url = mysql_real_escape_string($_POST['url']); $shoutcast_url = mysql_real_escape_string($_POST['shoutcast_url']); $site_name = mysql_real_escape_string($_POST['site_name']); $site_subtitle = mysql_real_escape_string($_POST['site_subtitle']); $email_suffix = mysql_real_escape_string($_POST['email_suffix']); $logo_name = mysql_...

SQL get polls that specified user is winning

Hello all and thanks in advance I have the tables accounts, votes and contests A vote consists of an author ID, a winner ID, and a contest ID, so as to stop people voting twice Id like to show for any given account, how many times theyve won a contest, how many times theyve come second and how many times theyve come third Whats the faste...

Wordpress SQL statement help needed?

Hello,I want to select with sql latest post from one category,I know how to select latest post from all category but dont know how to JOIN tables.Can someone help me with this,and explain a little. My sql statement. SELECT id,post_title,post_date FROM wp_posts ORDER BY post_date ASC How to select from one category,I'm trying some code...

Increment value on new row

Given this table design in a web application: CREATE TABLE `invoice` ( `invoice_nr` int(10) unsigned NOT NULL AUTO_INCREMENT, `revision` int(10) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`invoice_nr`,`revision`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci What's the most handy and reliable way to insert a new ...

Help me turn a SUBQUERY into a JOIN

Two tables. emails id (int10) | ownership (int10) messages emailid (int10) indexed | message (mediumtext) Subquery (which is terrible in mysql). SELECT COUNT(*) FROM messages WHERE message LIKE '%word%' AND emailid IN (SELECT id FROM emails WHERE ownership = 32) The usage here is that I run a search on emails (which is obviously...

Select most frequent from column in

Hi i have a columm in the table and i want to select the most common item from the selected column. The table is set up publication: id Title published I want to beable to select the most recurring places where publications have been published. Is this possible to do? Thanks in Advance Dean ...

Why is my MySQL query so slow?

Background: entities tables currently has 14,111 records articles table currently has 5211 records I am trying to find all articles that are active (completed) and have the entity 'google' # Finding articles that have the entity google takes: # 4 ms SELECT `Article`.`id` FROM `articles_entities` AS `ArticlesEntity` LEFT JOIN `entities...

Get threads linked to tags

I have 3 tables in my MySQL database : the Threads table (id, title) the Tags table (id, name) the pivot table ThreadTags (tagID, threadID) Let's admit I already have the tag IDs in array $tagIDs, now I want to have all threads linked to ALL those tags. My current solution is something like that : $stmt = 'SELECT id, title FROM Th...

PHP Database Dump Script - are there any issues?

Hey everyone, I found a PHP function to dump a mySQL database that someone else had written, and then cleaned it up and formatted it a bit. I wanted to know if I could get a critique of it. I have ran it, tested it on a Wordpress blog and the DB completely restores, but wanted to get some other eyes on the code. Specifically I am looki...

Connect to MySQL database from VBA without having MySQL installed

I can connect to a remote MySQL db from an Excel workbook on my machine no problem using the following connection string: Driver={MySQL ODBC 5.1 Driver};Server=server;Database=database;user=user;Password=;Option=3; ..but when others try to use the same workbook the connection can't be made ("Data source name not found and no defaul...

FETCH_ASSOC and SELECT * FROM two tables with the same column name

I have lot of MySQL tables with the same column name. So Im looking for PDO or SQL hack for SELECT * FROM more tables - which will return table names in result sets. Example: 'SELECT * FROM table0, table1'; Where both tables has 'name' column. But FETCH_ASSOC result returns only one 'name' - the last one. Result: echo $result["nam...

One Row, Multiple GROUPs

I have a list of reservations in a MySQL db, and I want to determine total number of slots reserved in 15 minute intervals. To do that, I need to 'unroll' (probably not the right word) each reservation, determine the overlap, and show total usage. The table is a list of reservations: ResID StartTime EndTi...

SQL Join Statement

I have a simple mysql query which is as following: SELECT DISTINCT(node.nid) AS nid, node_counter.totalcount AS node_counter_totalcount, node.title AS node_title, node_data_field_dep.field_dep_value AS node_data_field_dep_field_dep_value, node.type AS node_type, node.vid AS node_vid, node_data_field_type.field_type_value AS node_data_fi...

how to get the hierarchical menu from mysql

Hello, I have a table having hierarchical menus like "id" "parent_id" "name" 1 0 menu 2 1 item1 3 2 item1_1 4 1 item2 5 4 item2_1 ... ... and I have 100s of menu items here. In order to get all items in an array I have to write a recursive function like this getmenu function(parent_id = 1) { $items = mysql_query("SELECT id FROM tab...

Best Practices Syncing large quantities of Information

The question is relatively simple. I have copies of a database that run on user computers in MySql and I have a server database that aggregates the information that is stored in this client database when the user wants to 'Sync' that information with the server. Call the big Server databse server call the databse stored on the compute...

How to populate a field of all of the records in a MySQL table with uniqueid()?

Hello, I'm a newbe here and about PHP; be patient please :-) I have a MySQL table with 15000 rows; I need to populate a field of it (varchar(15)) - to be used in a way similar to a primary key – with the uniqid() PHP function. The algorithm is: positioning to the first row (record); generating a value with the uniqid() function; upda...

Mysql database Import Error in python

hi, i have installed python 2.6.4. i have downloaded mysql database module. but i don't know where to place that module in python package. when i execute the program it shows import error "no module named mysql db". please tell me where to place the module. ...

Basic permission in Bugzilla to separate clients

I'm trying to configure a Bugzilla instance, which will allow my clients to login, and file bugs for their website under development/maintenance. For e.g: I have created 2 products called "TestProject", "TestProject2" and a user called "TestClient". What I'm trying to achieve is when TestClient logs in, he can only see TestProject, Test...

Random() In MySql?

Is it possible to retrieve random rows from table X where flags==0? Using MySql and C# ...

Mysql – Detecting changes in data with a hash function over a part of table

Hi I need generate a single hash over some data in a table CREATE TABLE Table1 ( F1 INT UNSIGNED NOT NULL AUTO_INCREMENT, F2 INT default NULL, F3 Varchar(50) default NULL, .. FN INT default NULL, PRIMAR...