mysql

mysql group by confusion

so i have this table; mysql> describe player_weapon_stats; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL |...

How to show all days regardless of activity

I have two tables - quotes and bookings I am selecting "quote date" to show the day of the week but if a booking is made on a day without a quote, then there is no "quote date" and therefore this row is never displayed. How can I created a column that is just every day for the past 30,60 or 90 days then shows the number of quotes for t...

MySql Not accessing parent in subquery?

I get the error Unknown column 'm.id' in 'on clause' all my tables have a field called id. It appears to occur in my subquery. I use m.id in my join. So what the heck is going on? shouldnt i be able to access that var? how do i access media.id from my subquery? Also is the and not (select 1 part right? i am trying to exclude that tag....

Store and retrieve word documents with MySQL

Hi Fellas, I need to store and retrieve MS Word documents into MySQL 5.1 with Servlets. I've the code to upload a file, but I don't know can I feed into the table. I've used BLOB for the field I've to insert .doc files. Here's my code snippet to upload files: protected void doPost(HttpServletRequest request, HttpServletResponse respo...

Have you ever done SQL injection?

Hi all, I want to know if you have ever performed injection on a website using SQL injection for ethical hacking. What tricks/techniques have you have used (especially mysql)? ...

How to get the value from MySQL from table field like 'Feildname-1'?

Hai I am having the table USERS with the fields like USERACCNO FIELD-1 FIELD-2 . . . . . . FIELD-10 Now I want to get the Value from field-2 .SO I wrote a query like this SELECT FEILD-2 FROM USERS WHERE USERACCNO='1' But It returns error. So I wrote a query Like this SELECT 'FEILD-2' FROM USERS WHERE USERACCNO='1' Here I got the resu...

create dump file from database in mysql

mysqldump --host=localhost --user=root --password=sysadmin --no-data test > "C:\test1\ttt.dump"; This the command that i fire to create dump from mysql database , that's working fine and create dump with no data. but I want some table with data , this command create dump with table that all are blank. ...

MySQL: DECLARE CONTINUE HANDLER to continue on errors, printing a warning

I am reviewing / redesigning / refactoring a database and want to create a new database that stores pretty much the same data in a smarter fashion. One of the problems in the 'legacy' database is that it does not make proper use of keys and indices, so there is duplicate entries where there should be none. I have written a python script...

transpose columns to rows

The following query is working as expected. But how do I get the results in rows those are displayed in columns? select curdate() AS one, date_sub(curdate(), interval 15 day) AS two , date_sub(curdate(), interval 30 day) AS three , date_sub(curdate(), interval 45 day) AS four , date_sub(curdate(), interval 60 day) AS five , date_sub(...

mysql update multiple columns

I need to update 2 datetime columns, and I need them to be exactly the same, using mysql version 4.1.20. I'm using this query: mysql> update table set last_update=now(), last_monitor=now() where id=1; It is safe or there is a chance that the columns are update with different time, beacause of the 2 visible calls to now() ? I don't thi...

mysql : check the content change or not

hi i want to know how to find the column value change or not Example : table name = exam a b c 12a 32 sdf 23s df fds if i can search the row which c column have "fds". Query: select * from exam where c='fds'; but the same time,i have to check the all the field value is change or not. th...

Any idea on how to implement these database tables to Java?

I've started to develop my own mini project in restaurant reservation to improve my Java skills. At the moment, I create a table consists of number of tables in the restaurant (column) and time interval during the day (row). So for example, if someone booked a table at 11:00 on Table 4, that cell will become reserved and mark as b...

best practices of separating two dependent sets of data in mysql

Hi there! My application needs two sets of data, and I want to separate it logically on two parts. It's ideal to have namespaces for tables in one instance of mysql database, but I can't find any clues that this feature exists. So, I decided to split data onto two schemas (static & dynamic) in one instance of mysql. Though, my dynamic da...

How to efficient store graphs in SQL database (e.g., mysql)?

I have a tree like graphs and I need to store them into database. I am looking for information how to efficiently store and query graphs in SQL database. ...

Mysql query, three tables left join with group by.

Hi, I have query which provide wrong result, am I doing any thig wrong in this query SELECT b.nBoutiqueID , b.sBoutiqueName , b.Status , SUM(bs.nViewCount) nViewCount , SUM(ps.nViewCount) nProductViewCount, ...

What is MySQL's connection compression overhead on small datasets?

Is there any significant overhead to turning on mysql's connection compression for high load databases or is it always a winner? We have databases delivering very small datasets back to the requesting program (PHP) but these databases receive very large bursts of traffic from time to time. If I turn on connection compression am I likely...

Implementing a database structure for generic objects

I'm building a PHP/MySQL website and I'm currently working on my database design. I do have some database and MySQL experience, but I've never structured a database from scratch for a real world application which hopefully is going to get some good traffic, so I'd love to hear advices from people who've already done it, in order to avoid...

Was: Grab the last inserted id - mysql Now: Where should we call the last insert id ?

Here's the thing, I don't have access to code that inserts data into a given table. However, I need to add related additional data into another table. So, I was thinking about grabbing the last inserted ID and from there... insert the related data into that other table. Since I don't have access to the statement, I believe that mysql la...

WHERE statement issues UPDATEing all rows

I have an issue in my app where the "change my password" functionality has reset ALL user's password to the same value. I restored a backup, so no major problems, apart from this awful bug through no fault other than my own. Obviously this was due to the WHERE condition in the UPDATE statement having no value. This was via an active rec...

Sample app required with rails mysql and apache

I want a sample application which is of Rails and the database Mysql and the server Apache. Please let me know if any such application is available. Thanks in advance I am using Opensolaris machine. ...