mysql

PHP & MySQL url rewriting question.

Can I rewrite a url by using the value 6 from ?cat for example, and checking my MySQL database for the value 6 category name html using PHP & MySQL if so how? Current url. http://localhost/index.php?cat=6&sub1=8&sub2=24&sub3=81 New search friendly URL displayed in browser. http://localhost/html/basics/forms/select-tag/...

Why can't I INSERT INTO?

So this might be dumb, but I can't get anything to insert into a MySQL on a certain account, and I've been staring at this for two hours. I'm a newbie to PHP, so I could very well be doing something dumb. I attached a screen shot of the DB I am trying to INSERT INTO. Find an image of what I'm talking about at http://dillondoyle.com/file...

Cascading counts for related groups: class, school, and district

I have a table like this: Student_id char(10 classroom_code char(5) school_code char(4) class_count int(4) school_count int(4) district_count int(5) It contains a school district's population of kids for a single grade level (3643 students). I want to do cascading counts for the class, ...

mysql how to NOT update datetime?

I have a table where it has two datetimes, one of them is a 'completed' datetime, therefore, if it is NULL then the user has not completed. I am trying to do an update, to update their mobile number. How can i do it so it does not update the datetime? currently if the datetime is null it gets set to the earliest possible time. here i...

mysql: how to collect the array data?

hi all. I have a mysql code that needs to be improved because of my limited knowledge. i am new in php-mysql.I have data arrays at my DB and I want to show data such as: Date Model Qty Name 2010-08-23 boo 2 Steve 2010-08-24 boo 1 Steve 2010-08-25 boo ...

Rows in a table that have no counterpart in another two tables?

SELECT left_tbl.* FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id WHERE right_tbl.id IS NULL; The code above works beautifully when you are searching rows from left table without a counterpart in one right table. But how do I find rows from left table without a counterpart in two right tables? ...

How do I join 3 tables using mysql

I have the following tables: TABLE: companies c FIELDS: id, name, description TABLE: departments d FIELDS: id, name, description TABLE employees e FIELDS: id, company_id, department_id, name I'm trying to get a list of all employees for company 1 and also get the department name (d.name) into the results of the row. Here's my origi...

How to scale out by evolving from database partitions to sharding?

Say I have a MySQL table: CREATE TABLE tweets ( tweet_id INT NOT NULL AUTO_INCREMENT, author_id INT NOT NULL, text CHAR(140) NOT NULL, PRIMARY KEY (tweet_id) ) PARTITION BY HASH(tweet_id) PARTITIONS 12; All is good. The table lives on a single server - Server1. But eventually I may want to scale out. So I'd want to shard the table and...

How to avoid inserting data twice in MySQL using PHP and mysqli

I'm trying to catch error messages returned from a mysql server on insert failure. The below method works fine when fetching data, but on insert, the 'if' statement below inserts the data a second time. How can I re-write this to catch error messages without inserting the data again. $mysqli = new mysqli("localhost", "user", "pass"...

PHP form not uploading file

I have a PHP form that is inserting information into a database. It all works except for the file upload. The filename needs to get placed inside the "image" column in the database table and the file needs to be put in the directory as well. Funny thing is that this uploader was working yesterday. :-S Please can someone just review m...

MySQL query running really slow for large database

I am trying to extract duplicate rows from my database. I have a listings table and a listings_meta table which holds additional information. The listings_meta table has over 16,000 rows. When I run the query below it runs REALLY slow. I don't understand why. Is there something wrong with my code? SELECT l.id FROM listings AS l LEF...

Counting some data array not work

dear all.can you tell me how to collecting this data in mysql: item colour nut brown nut black i want the result like: item colour_qty nut 2 and i have try like this, but didn't work: SELECT item, COUNT(colour) AS colour_qty FROM mytable How do i do that?thanks. ...

How can I select all ids with the pattern lastname.firstname

I am looking to select ids that are backwards from some standards we have outlined. What I would like to do is this: SELECT iid FROM login WHERE iid LIKE lastname'.%' In theory this should catch everyone where there id is lastname.firstname instead of firstname.lastname. Either way any suggestions would be awesome. Thank you. ...

PHP & MySQL looping problem.

I'm trying to loop once with the $cat_id to grab its id and category values for the $url value and then add the id and category values to the $parent_cat_id and $sub_cat_name arrays and then loop the $parent_cat_id value just added to the array to find its id and category values and add them to the arrays until all the $url values have b...

What is the difference in View and EER Diagram?

I quite confuse with both. First, both might seen the same. May I know how the View and EER Diagram is apply? ...

Which should I use for working with a large amount of data, MySQL or SQLite?

I need to work with a fairly large amount of data, and am considering both MySQL and SQLite. So I'm trying to get a good, high-level overview of both packages: How well do each handle large databases? Is SQLite as much of a handful to work with as MySQL? Are there any good (web-based) resources comparing these two? ...

How to store hashes in MySQL databases without using text fields

I'm storing unique user-agents in a MySQL MyISAM table so when I have to look if it exists in the table, I check the md5 hash that is stored next to the TEXT field. User-Agents { id - INT user-agent - TEXT hash - VARCHAR(32) // md5 } There is any way to do the same but using a 32-bit integer and not a text h...

mysql setting a negative integer value to a primary auto increment field which is int

Hi, I have a table which maintains categories from another site. I populate this table with the data i fetch from other site as xml. The data are divided as categories and products. Some products does not have a category and the category xml does not have the others category. So what i thought was to add a category others and settin...

Two transactions seem to block each other but none of them is waiting

I have two transactions running in a mysql database, neither of which seems to make any progress. Both hold some locks but as far as I understand they don't conflict. Both transactions are in state "ACTIVE" (I would have expected that one of them be in a waiting state if it were blocked by the other). I've attached the "TRANSACTIONS" ...

CodeIgniter - numbers in sql query are masked with ``

Hello, i'm using CodeIgniter for developing a community board. As I'm using nested sets to get a nested forum hierarchy, I have to run a lot of queries such as: SELECT `id` FROM `forums` WHERE 1 BETWEEN `lft` AND `rgt` My problem: CodeIgniter is replacing the "1" by "`1`" because the "1" is recognized as a column name. Of course, the...