mysql

is Payment table needed when you have an invoice table like this?

this is my invoice table: Invoice Table: invoice_id creation_date due_date payment_date status enum('not paid','paid','expired') user_id total_price I wonder if it's Useful to have a payment table in order to record user payments for invoices. payment table can be like this: payment_id payment_date invoice_id ...

Most efficient way to store IP Address in MySQL

What is the most efficient way to store and retrieve IP addresses in MySQL? Right now I'm doing: SELECT * FROM logins WHERE ip = '1.2.3.4' Where ip is a VARCHAR(15) field. Is there a better way to do this? I'm using Python. ...

MySQL Query For Copying Contents Into Another Field, Same Row

Is there a single query (subqueries in it are allowed) where I can copy the content of one field into another field, per row. Example: price, and priceBackup Records: 45.55 47.77 45.55 copies into priceBackup for that specific row, 47.77 copies into priceBackup for that specific row. I do have a primary key, auto increment on it u...

Is it possible to group rows twice in MySQL?

I have a table like this: someid somestring 1 Hello 1 World 1 Blah 2 World 2 TestA 2 TestB ... Currently I'm grouping by the id and concatenating the strings, so I end up with this: 1 Hello,World,Blah 2 World,TestA,TestB ... Is it possible to do a second grouping so...

Show one at a time?

I have a script on my website that shows messsages from a mysql database. Now I want to make it so it only pops up one message at a time. Anyone want to shed some light on this? Windows Vista PHP - Mysql - Ajax - JS I can't really provide a code sample but here is some pseudocode: if(ID == 1) { // SHOW ID++; } // Show #2 ...

PHP next MySQL row - how to move pointer until function checks true?

I have a PHP script which takes a value from a row in my MySQL database, runs it through a function, and if it determines it's true returns one value, and if it's false, it needs to go to the next value in the database and check that one until eventually one returns true. I think I need to use mysql_fetch_assoc, but I'm not really sure i...

ManyToManyField "table exist" error on syncdb

When I include a ModelToModelField to one of my models the following error is thrown. Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager utility.execute() File "/Library/Pytho...

How do I set ORDER BY params using prepared PDO statement?

I'm having problems using params in the ORDER BY section of my SQL. It doesn't issue any warnings, but prints out nothing. $order = 'columnName'; $direction = 'ASC'; $stmt = $db->prepare("SELECT field from table WHERE column = :my_param ORDER BY :order :direction"); $stmt->bindParam(':my_param', $is_live, PDO::PARAM_STR); $stmt->bind...

Trouble pre-populating drop down and textarea from MySQL Database

I am able to successfully pre-populate my questions using the following code: First Name: <input type="text" name="first_name" size="30" maxlength="20" value="' . $row[2] . '" /><br /> However, when I try to do the same for a drop down box and a textarea box, nothing is pre-populated from the database, even though there is actual conte...

Mysql CASE - WHEN - THEN - returning wrong data type (blob)

Hi there. Im creating customizable product attributes in a web store - each attribute can have different type of data, each data type is stored in a separate column using corresponding mysql datatype. I Have a query like: SELECT products.id AS id, products.sku AS sku, products.name AS name, products.url_key AS url_key, attributes.name...

database datatype size

Just to clarify, by specifying something like VARCHAR(45) means it can take up to max 45 characters? I remember I heard from someone a few years ago that the number in the parenthesis doesn't refer to the no of characters, then the person tried to explain to me something quite complicated which I don't understand and forgot already. And...

How to make an add friend/defriend function in PHP?

I have created a site where people can create a profile. But I am trying to figure out how to start on making an add friend button so users can have friends. In my user table, i have user_id, first_name, last_name, email, etc. Should I somehow relate the user_id of the user and the friend in a friend table? I am a novice to programm...

create and insert values using mysql JDBC

Hi all, I have the sample code. public void UpdateTable1() { for (int t = 0; t < 20; t++) { if (consumer == 1 && number == 1 && provider1 == 31 && feedback == 1) { try { Class.forName(driverName); con = DriverManager.getConnection(url + dbName, "root", "mysql"); t...

SQL Grouping with multiple joins combining results incorrectly

Hi I'm having trouble with my query combining records when it shouldn't. I have two tables Authors and Publications, they are related by Publication ID in a many to many relationship. As each author can have many publications and each publication has many Authors. I want my query to return every publication for a set of authors and i...

What is the most efficient way to populate class attributes with a row from a database query?

Looking to have a database query set all the instance variables in a class: Example: def populate(self, if): #Perform mysql query self._name = row['name'] self._email = row['email'] ... What's the fastest way to do this? Or is this not recommended (with a better approach)? Thanks. ...

Unable to get multiple connection to MySql on Windows 7

I have installed MySql on windows 7 ... issue is i'm unable to get multiple connection to MySql . If I connect to MySql through command line and at the same time open an other MySql command line client it goes into wait state, as soon as I disconnect the first one later one gets connected. Because of above issues I'm unable to run tomc...

PHP & MySQL fckeditor integration?

I just downloaded fckeditor and dropped the folder into my root directory but I don't know how to install the fckeditor into my forms for example, I wanted to integrate the fckeditor into the About Me and My Interests form fields in the form below, but I don't know how or even how to change the fckeditor skins. Can someone show me how to...

Receives System.Byte[] in GridView when MySql's DateFormat Function is used

I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail, Date_Format(FeedbackDate,'%m,%d') as 'Feedback_Date' from FeedbackDetail where EMailID not like '' and InstanceCode =5 and I'm binding this data with GridView in asp.net but at the column of Feedback_Date, instead of Da...

Implementing database redundancy with sharded tables

We're looking to implement load balancing by horizontally sharding our tables across a cluster of servers. What are some options to implement live redundancy should a server fail? Would it be effective to do (2) INSERTS instead of one ... one to the target shard, and another to a secondary shard which could be accessed should the pri...

Is It Possible to update any trigger in Information schema?

Is It Possible to update any trigger in Information schema? ...