mysql

How can I work out what curdate() in MySQL is returning?

I'd like to know when I write a query like SELECT id FROM users WHERE expiry > curdate() How can I work out what the curdate() is returning? I just switched servers of a site and it appears to be throwing it out, by perhaps returning a different curdate(). Thanks ...

WordPressMU - get blog list, alphabetically sorted by blogname

In WordPress MU, I've tried writing my own query for this but can't seem to get all of the joins I really need. The result set I'm looking for would be something like: blog_id blog name blog path owner first name owner last name and return it all alphabetically, by blog name. The trouble I'm having is that the first and last name of t...

Using a table to provide enum values in MySQL??

Is there a way to map one of the the columns contents of a MySQL table to an enum on another table in MySQL? I thought this would be a no brainer, but there doesn't seem to be any info that I can find on the subject. Any advice or help on this matter would be cool and if it's not possible, does anyone know of an internal reason why it w...

Print rows that dont exist in table???

Simple question. I have a query that sums rows grouped by date. Basically, it counts how many membership applications in a day and prints out the results day by day. Naturally, if there are no applications in a day, it doesnt show that row (example below 15th and 17th had no applications..... Date | Applications ------------...

what is the best way to prevent sql injection in mysql

Hi all, i don't know much about sql injection. I want to know that what is the best way to prevent the sql injection in mysql? Like how should i insert data in the database, How should i fetch them from DB, how to execute search query, update query in mysql. Upto here i know that addslashes is used to prevent the sql injection in mys...

Using Subquery in Select statement.

I've got a query that outputs the following table: (0) Age <= 19----------76-------0.12 (1) Age 20 – 24--------661------1.06 (2) Age 25 – 29-------4060------6.53 (3) Age 30 – 34-------7231------11.64 (4) Age 35 – 39-------9281------14.94 (5) Age 40 – 44-------9539------15.35 Total ----------------30848 -----49.65 The first...

use mysql_real_escape_string() but allow names with apostrophes

I use mysql_real_escape_string() to validate all user inputs before I insert them in a sql database. One of the fields is name, and we've had issues with users with names like O'Reilly. Is there any way to use mysql_real_escape_string() to block injections but allow these names in the db? ...

Connectivity between Mysql & .net 3.5

Hi i want the connection string to connect the MySQL from the .Net 3.5 SP1 ...

automatic web shop creation

In one of my prject i need automatic webshop creation. it will similer to bigcartel.com. can anyone hint me what to do? is there any tutorial available? Thanks for your comments. regards Tarique ...

mysql delete row when user exits

i am in a situation where i want the db to delete a row when the user exits the application. even in the middle of the application. how can it be done? to be more specific, consider a survey of 10 questions. i am storing the user's selections in a DB. now suppose the user exits at the 5th question. i want to delete the user's records th...

Sphinx: Filtering MVA on multiple fields

I would like to be able to filter my orders on an amount range AND a specific user_id The expected result would be to get only the orders where the specified user did a bid on in a certain amount range. For example there is an order with id 1. User 5 bid on it for an amount of 200. Now if I want to filter I set the user_id filter to 5 ...

SQL : find rows and sort according to number of matching columns?

Let's imagine that we are having "cars" table with such a simple structure... car_id INT color ENUM('black','white','blue') weight ENUM('light','medium','heavy') type ENUM('van','sedan','limo') Fist, I'm selecting car (1, black, heavy, limo), then I'd like to get list of related cars sorted by number of matching columns (without any c...

Query sql with like operator from two tables

I need something like: select * from table1 where name like %table2.name ...

Querying remote MySql server.

Hi Guys, I think I have a straight forward question. I'm writing a system that allows users from company A to single sign on to the system and for this I go back to the central database of users at company A and validate the user credentials passed to me. Currently my implementation involves building up my query using a stringbuilder a...

SQL (mySQL) update some value in all records processed by a select

I am using mySQL from their C API, but that shouldn't be relevant. My code must process records from a table that match some criteria, and then update the said records to flag them as processed. The lines in the table are modified/inserted/deleted by another process I don't control. I am afraid in the following, the UPDATE might flag som...

Selecting a specific Date Time from a datetime field in MySQL

How can this be done properly in MySQL? I want to select records that are created after a specific date AND time... I thought something simple like this would do the trick, but I think it needs a bit more to it to work. SELECT `modified` FROM `Blog` WHERE `modified` > 2010-01-08 16:01:01 Any help appreciated. ...

MySQL "incorrect string value" error when save unicode string in Django

I got strange error message when tried to save first_name, last_name to Django's auth_user model. Failed examples user = User.object.create_user(username, email, password) user.first_name = u'Rytis' user.last_name = u'Slatkevičius' user.save() >>> Incorrect string value: '\xC4\x8Dius' for column 'last_name' at row 104 user.first_name ...

Changing the MySQL query delimiter through the C API

How can I change the MySQL query delimiter using the C API? I tried sending DELIMITER | as a query, complained about ..the right syntax to use near 'delimiter' at line 1.. Tried DELIMITER |; too, no luck. Tried DELIMITER |; SELECT 1|, no luck. :( The reason I ask is that I need to create a trigger through the C API such as the followin...

Creating a messaging "system" in DB (most especially MySQL)

Hi guys, Sorry, I have a concern: I have a table successully created in MySQL: CREATE TABLE IF NOT EXISTS MESSAGE ( MESSAGE_ID BIGINT NOT NULL AUTO_INCREMENT ,AUTHOR_ID VARCHAR(30) NOT NULL ,TITLE VARCHAR(100) NOT NULL ,MESSAGE VARCHAR(4095) NOT NULL ,UNREAD_FLAG ...

Django: Storing values into MySql from Templates

I have used a checkbox in my html template, On submit, i want to store these Boolean values into the MySql Table. Please advice me on, How should i code my views such that it accepts values from Templates and stores it to the database. Also suggest , if any alternative method is possible. ...