mysql

How to kill locked mysql queries

Hi, I am creating and testing a mysql join query but each time so far it causes the database tables to lockup and the site hangs. I have to then call the host and they kill the locked queries. Is this something I can do from phpmyadmin so not to bother them while I tweak the script to work? Thanks for any reply. ...

Doctrine Default Primary Key Problem (Again)

EDIT: Paul Witschger (doctrine-user group) suggested I change the default primary key (system/application/plugins/doctrine_pi.php) back to 'id' and change any primary keys in my MySQL tables that differ from this. It worked. Thanks Hi, Should I change all of my uniquely-named MySQL database primary keys (for all tables that use Doctrin...

Video learning for database design

I'm trying to learn good relational database design (using mysql and php if that makes any difference). I've already done some database work, so I'm not totally clueless, but I suspect that my solutions may not have adhered to best practices for efficient searching, optimization, etc. Can someone suggest a good set of videos on the top...

Sum in array with match value

I would like to do a simple sum per salesid in php - mysql after cross calculation between date (2 tables) to get the real time commission, all the value already come out correctly but I have a problem with the final sum per sales id. Every time there is a change in the input commission form, the new value is inserted: salesid commis...

MySQL 5.1.41 leading zero is deleted

Hello, I have a MySQL database where i want to store phonenumbers among other things. The fieldtype is INT(10) When I try to insert a number starting with a 0, like 0504042858 it's stored like 504042858. This only happens with zeros when the number start with any other number it's stored correctly. What am I doing wrong? ...

Are indexes good or bad for a large database?

Hello All, I read on MySQL Performance Blog that when tables are large, it is better to scan full tables, instead of using indexes. I have a table with tens of millions of rows. When conducting queries, if I use no indexes, then queries are 24 times slower than with indexes. I know lot of things may cause this (e.g., are rows stored se...

php + MySQL editing table data.

This question is relating to 2 php scripts. The first script is called pick_modcontact.php where I choose a contact (from a contact book like phone book), then posts to the script show_modcontact.php When I click the submit button on the form on pick.modcontact.php. As a result of submitting the form I am then taken to show_modcontact.ph...

select distinct over specific columns

A query in a system I maintain returns QID AID DATA 1 2 x 1 2 y 5 6 t As per a new requirement, I do not want the (QID, AID)=(1,2) pair to be repeated. We also dont care what value is selected from "data" column. either x or y will do. What I have done is to enclose the original query like this SELECT * FROM (<original ...

Timezones, daylight saving etc...

We have a site that currently runs auctions at a certain time (picked by user) this was all working fine, as when the server hit that time the auction would start. We then had to add timezones, dependant on where the user lived. This would then add or take away a certain amount of hours depending on the drop-down selected, we again had t...

PHP - displaying 1 random record for each week

I want to display 1 random record from a database based on the week. I need to determine if it's a new, and if it is a new week, then select the record and display the new record. I'm thinking I can just use a single day of the week to generate the new record, either way will work. I'm really having a hard time conceptualizing how I...

How can I combine result and subquery for IN comparison (mysql)

In order for a school project i need to create the following situation within one mysql query. The situation is as such, that a child's tags and a parent's tags need to be combined into one, and compared to a site's tags, depending on a few extra simple equals to lines. For this to happen I only see the option that the result of a subq...

How to check if a checkbox/ radio button is checked in php

I have this html code: <tr> <td><label><input type="text" name="id" class="DEPENDS ON info BEING student" id="example">ID</label></td> </tr> <tr> <td> <label> <input type="checkbox" name="yr" class="DEPENDS ON info BEING student"> Year</label> </td> </tr> But I don't have any idea on how do I check...

How to use Mysql variables with Hibernate ?

Hello, I need to use a native sql query in Hibernate with use of variable. But hibernate throws an error saying: Space is not allowed after parameter prefix So there is a conflict with the := mysql variable assignment and hibernate variable assignment. Here is my sql query: SET @rank:=0; UPDATE Rank SET rank_Level=@rank:=@rank+1 O...

How do I simplify this php script

Any suggestions on how I can simplify the php script below?This was my previous question: http://stackoverflow.com/questions/2712237/how-to-check-if-a-checkbox-radio-button-is-checked-in-php that is linked to this one, What I'm trying to do here is to output the data depending on the checkbox that is checked. But my code isn't really goo...

Alternative for composite key

hi, i have database structure where all the tables are having two columns for primary key. for an example the table Author has two columns like AutherId which is a auto increment number and the pc_id which is unique to that pc the those are the composite keys for the table. but when it comes to relations i have to define the both colum...

mysql restore file.sql syntax error using command line

when I input mysql -u root -p XXXX dbname < c:/filename.sql alway get this error "error 1064 <42000>:" you have an error in your SQL suntax; check the manual that corresponds to your MySql server version for the right syntax to use near ..... what is wrong with this statement? ...

PHP & MySQL - saving and looping problems.

I'm new to PHP and MySQL I want a user to be able to store multiple names and there meanings in a MySQL database tables named names using PHP I will dynamically create form fields with JQuery every time a user clicks on a link so a user can enter 1 to 1,000,000 different names and there meanings which will be stored in a table called nam...

MySql insert data in multiple table at a time

hi, i have a query regarding to insert data in multiple table.. i have a two tables. one is item table and second is field table. itemid from item table reference in the field table. i want to insert data in both table with one query at a time. any idea about it. ...

User's Post count from specific category [Wordpress]

Hello, I want to show user's post count from specific category. Currently, I can only be able to query all posts. My code is like this <?php $userpost_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type ='post' AND post_author = '".$curauth->ID."'");?> <?php echo "<span>Total post: </b>...

How to load file into mysql DB on a shared hosting platform?

A process running on my machine collects data from various websites and stores it in the local mysql db. Same data is exported using SELECT INTO OUTFILE and FTPed to the shared host every few hours. My hosting provider doesn't allow LOAD DATA INFILE to be executed on the shared host? What are my other options for automated/scheduled load...