mysql

sql sort numeric then alphabetically

in this example : 10-20 20-40 50-60 v k r a 12 month 1 month how can i sort it in this order ?: 10-20 20-40 50-60 a k r v 1 month 12 month i use abs(value) but in the alphabetical case doesn't work ...

Any Mysql guru who knows how to handle a custom group calculation scenario in 1 query?

I hope any sense can be made from my explanation. I was able to create the query, however my query only works for Items related to Containers, AND only if no more than one Items are related. I really hope anybody can be of any assistance! Consider the following objects: Container Person Item I have one table where instances of all o...

What is the best way to set a MySQL user variable in a Java, Spring MVC, Hibernate with Annotations web application?

I need to be able to set a MySQL user variable that is used in a trigger in a Spring MVC Hibernate web ap. This user variable is used in MySQL triggers on the tables that are being manipulated by Hibernate. I need this user variable to be correctly set during all of Hibernate's write accesses to the database. Unfortunately HQL does no...

turn on mysql profiler globally

I want to profile all mysql sessions using mysql profiler, how can I turn on profiling globally? thanks! ...

Problem connecting to external mysql database

Hello, My problem is this command produces an error when I tried to connect from our server to another external server : mysql -h db.hostname.com -u username -pP@ssword database_name And this is the error : ERROR 1044 (42000): Access denied for user 'username'@'%' to database 'database_name' I already asked the external server admi...

mysql query to three tables, want to use JOIN instead subquery

I want to use join instead subquery to find the trade id not exist on trade_log filtered by ip and current date for mysql syntax below. SELECT plug.id as a, plug.url as b, trade.id as c FROM plug, trade WHERE trade.id = plug.trade_id AND trade.id NOT IN (SELECT trade_log.trade_id ...

MySQL Add Data Based on Unique ID

Hi, I've been looking around for an answer to a MySQL Query question but have not been able to find an answer. Any help is appreciated... Ps. I'm a beginner. Issue: I have two tables, one is a main table with several columns and a unique ID column (sequential numbers) which is also the key. This table has had some rows of data deleted ...

How do i store array of image names dynamically into the database using PHP

Hi there, i am using the jQuery Plugin Uploadify to upload files, and i store the image name with path into the database with simple mysql query and then retrieve it. my MySQL database table is using the following entities, id int(20) image_url varchar(255) my image store procedure is such as, i first rename the file, give it a un...

mysql index use with IN ()

Database structure (MySQL): A (model) * id B (model) * id C (content table) * id * b_id * date A_B * a_id * b_id a habtm b, and b has_many c The goal is given A, get all C's in descending order by date. Indexes: on C for b_id, date on A_B for a_id I tried the straight up B join C join A_B, but it doesn't se...

reducing execution time of indivual php files that are not mandatory to the system like Ajax JSON requests.

I want to make sure AJAX responses from dynamic JSON pages does not slow down the server when the SQL queries take too long. I'm using PHP, MySQL with Apache2. I had this idea to use ini_set() to recude the execution of this pages with the inline use of the mentioned method or the set_time_limit() method. Is this effective? Are their any...

How to join four tables in php mysql ?

Hi i have my query I want to join 4 tables here is my code SELECT c.name, u.username, u.thumbnail, q.question, a.answer, a.uid, COALESCE( COUNT( a.qid ) , 0 ) AS cnt FROM question_category c INNER JOIN question q ON q.cid = c.id LEFT JOIN answer a ON a.qid = q.id LEFT JOIN hmuser u ON u.id = q.uid GROUP BY c.name ORDER BY cnt DE...

DB Design - Contextual constraints

I have a pair of tables with parent-child relationship. domain: id int not null auto_increment primary_key domain varchar(100) not null domain_url: id int not null auto_increment primary key domain_id int not null path varchar(512) Here I want to keep path unique with in one domain. Across the domain path...

Rails - how to pull specific sorted data out of database

Hey all, I have a database with columns (username, points). I am making a call to return some fields from this database to use in a program. I want to pull: The top 10 users with the most points The 5 users above/below the username requesting the rankings I can pull the top 10 easily enough... top_users = UserPoints.find( :all, ...

A Database Tool to check changes happened overnight and upload to MasterDB

HI I have 5 different database and a Master DB with same Schema .I am looking for a tool which can check any changes( new row insertion ) has happened since my last update and Sync with my Master DB . Is there any tool available for this ...

Integrating freely available Asp.Net forum with a Asp.net web app on a MySQL DB

We have just finished delivering a (large-ish) Asp.Net 3.5 Web Application project which uses MySQL as the database. We have used the MySQL Membership Provider along with SubSonic 2.2 to finish the project in. However, now the client wants a Forum to go along with the website - such that when a user signs up into our site, an ID is als...

Timezone offsets (and st/dst changes) in MySQL / PHP

Basically I have a site that allows stores to store their open/close times. Now, I'm trying to add the feature of giving their visitors the ability to see if the store is closed. I understand I can run a query like: SELECT * FROM `store_hours` WHERE TIME(NOW()) BETWEEN `opens` AND `closes` ... and the query works and retrieves the s...

delete from table1,table2,table3 where?

Hi there, If all tables I want to delete from have the column gamer_id can i do a delete from table1, table2, table3 where gamer_id = 123? or is there a different syntax? ...

Exception: Super privilege, a MySql+ASP.NET+Linux mess

When i access any page on my site i am greeted by the error below. I wonder what happened so i checked my mysql file and i see some of my tables created by not all. i looked in my table creation code and it is inside a transaction so i am confused. I write quick code to dump the stack via Application_Error and it doesnt catch that error ...

How to lock particular row in Mysql?

Hi Friends, I am having the table called user and In that table I am having the field called lastusedecnumber.I need to access that lastusedecnumber and I will add one to that.During that accessing time I need to lock that particular user row.Not the entire table.How can I achive this?Table Type is MyISAM. ...

What is wrong with this MySQL Query?

It's 12:30am and I have been coding for 9 hours straight. I really need to get this project done, but MySQL is messing with my deadline. Could you examine this snippet for me and see if you can find out what is wrong? PHP/MySQL Query $q = $this->db->query("SELECT * FROM bans WHERE ip='".$ip."'"); Keeps returning the following error.....