mysql

How to update two tables with MySQL and PHP?

I was wondering how do I update two tables using mysql and php? How would I add the second table to the code? Here is the code below. $dbc = mysqli_query($mysqli,"UPDATE tags SET count='$tag_info_count' WHERE id='$tag_info_id'") ...

SQL: Refactoring a GROUP_CONCAT query

My eventual goal is to generate tag links for blog posts, the tags relating to the post. Currently my query has a GROUP_CONCAT which grabs relating tags and the returning tags column value is something like: 'Brooklyn, Manhattan, New York' from SELECT post.id, post.name, GROUP_CONCAT( tags.name order by tags.name ) AS tags...

Similarity Between Users Based On Votes

lets say i have a set of users, a set of songs, and a set of votes on each song: =========== =========== ======= User Song Vote =========== =========== ======= user1 song1 [score] user1 song2 [score] user1 song3 [score] user2 song1 [score] user2 song2 [score] user...

How do I show unique constraints of a table in MySQL?

I created them, but I forgot which ones they are. I just want to show them. remove all the constraints on a table. ...

How do I remove all unique keys from a table?

I have a table, and I just want to remove all unique constraints on it. I tried dropping the table and remaking it , but it won't work. There is still constraint. ...

Fixed Timetable DB Design

I want to let my users specify which hours / days they want to be contacted, I though of creating a fixed timetable with the 7 days of the week and let the user specify which hours he has free. I'm having a little trouble figuring out how I would store that info in the database, can anyone help me with a good table design for this situa...

How to MYSQL UPDATE fieldINT!=‘4’ doesn’t work

Im trying to UPDATE queueStatusINT WHERE statusINT is 8 and queueStatusINT is NOT equal to 2 and type is $type. But I keep getting an error: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ queueStatusINT!='2’, type=’int'...

Select duplicates with PHP & MySql for merging process

I wrote some code to select duplicates and group them using first and last names. I gather them into a multidimensional array and dedupe/merge them using jQuery/Ajax on the resulting page. I would like to ask if there is a better method of creating the array than how I'm doing it. Here is my code. Thank you. $dataArr=fetchDups($conn, 13...

MySQL: Duplicated Data VS More Queries

Please take into consideration this is a MySQL Question for Web Development. Currently I'm designing the database structure for a User Authentication System and I came across one question, that I myself can't figure it out: Is it better to have duplicated data instead of making more queries? Here's a little background, currently my us...

MySQL: How to exclude duplicates with a join?

I am trying to select all of the users who belong to a group. My group_members table keeps track of which groups a user belongs to. group_members ( group_id , user_id ) So in my group_members table, a user_id may appear multiple times because a user can belong to many groups. I'm using an innerJoin() to pull the user information for e...

PHP/MySQL how to insert and or update two MySQL tables?

I was wondering how can I update my two database tables using PHP and MySQL? I want to add a second table called tags_2 that will check if a tag already exists and if it does add it to the current count in the table and if the tag does not exist add it to the table. I hope I explained it right? I basically need help in adding the corre...

Frustrating MySQL CREATE PROCEDURE error

Hopefully this is a nice quick one to resolve. Here is my .sql file: USE my_db; DELIMITER $$ CREATE PROCEDURE searchLocation(IN argQuery VARCHAR(32), IN argLimit INT) BEGIN SELECT DISTINCT `suburb`, `postcode` FROM `location` WHERE `suburb` LIKE '%argQuery%' OR `postcode` LIKE 'argQuery%' LIMIT argLimit ; END $$ DELIMITER ...

mySql Connector exception (C++ library for mysql) when inserting row into non-empty table

I have not done much database programming at all. I am working from some example code for using MySQL Connector/C++. When I run the following code I get a crash on the last line in some std::string code - but it ONLY crashes when the table is not empty. If the table is empty, it inserts the row and works fine. If the table is non emp...

How can I use MySQL table partitioning on this table?

I have a table that essentially looks like this: CREATE TABLE myTable ( id INT auto_increment, field1 TINYINT, field2 CHAR(2), field3 INT, theDate DATE, otherStuff VARCHAR(20) PRIMARY KEY (id) UNIQUE KEY (field1, field2, field3) ) I'd like to partition the table based on the month and year of theDate, h...

How to make a subdomain + files on it, acessible to people with special privileges?

Im adding a premium section to my site which already has free registration. People who will pay a monthly fee will have access to content (html, images and media files) that will be hosted on a subdomain lets say..... content1.domain.com How would I make it so files that are delivered via that subdomain, cannot be hotlinked or copied, u...

Only update the MYSQL field if the field contains null or 0.

I want to insert data into a table, then if the table already has that same input value of rName then it is to update this row (as rName is a unique index) which it all does well. But on the UPDATE I would like it to only UPDATE the fields IF the field doesn’t already have something in it (NULL). INSERT INTO $table (`rDate`, `rName`,...

Login, logout and duration time in php and mysql?

I would like to store the login, logout and duration time in database. The login time is created when the user is authenticated(successfully logged in) The logout time is created when the user clicks the logout button The duration is logout - login time. (logout minus login) But the problem is, what if the user didnt click the logo...

How to set trigger on contacts database in Android

Hi, I have a requirement wherein I need a list of all the contacts that are edited/changed. As per the Android documentation, _SYNC_DIRTY will be set every time a contact is edited. But, there seems to be a bug in this, which makes this always set to 1 (no matter what), even is we explicitly set it to 0. So, I was wondering if I c...

Mysql column to utf8_bin

Hi. I have a table in mysql. I want to change one of the columns to have utf8_bin as it's collate attribute. I know the command to do for whole table is like: ALTER TABLE temp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; But how do I do it for individual columns? Thanks for the help ...

Submit Value With Javascript

Hi All, Im a little stuck with the following function. Please note, Im a total noob with javascript/ajax, so please bare with me: <script type="text/javascript"> function removeElement($parentDiv, $childDiv){ if (document.getElementById($childDiv)) { var child = document.getElementById($childDiv); var par...