mysql

MySQL table structure question.

I've been looking around on SO and have been seeing a lot of questions about category tree menus and was wondering how would my MySQL table or tables look like so I can add many categories and count less sub categories and display them on my web site. Note I will be using PHP & MySQL. ...

Massive Database w/ Fulltext Search - Sphinx, Lucene, Cassandra, MongoDB, CouchDB....

Hello, Our company is working on a project that requires a database with 30-50 million rows of product data. These rows contain text that needs to be searched concurrently thousands of times per second. Moreover, each search needs to take less than one second to execute. So, all in all, we have a 50M row database that needs to be searc...

Newbie with PHP. Keep getting same database error even after I modified my source.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'dbuser1'@'localhost This is probably something stupid, but I created some code to access my database from a PHP script but there was an error (dbuser1 doesn't exist) at the first run and now its stuck with the same error even if I change the username to anoth...

How to create a link to a sub category from a page that is associated with a parent category using MySQL & PHP.

How would I be able to display a url value from a sub category listed in my MySQL database that looks something like the example below? index.php?cat=category&sub=sub-cat-1&sub2=sub-cat-2&sub3=sub-cat-3 Here is the MySQL table. CREATE TABLE categories ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, parentID INT UNSIGNED NOT NULL DEFAULT...

PHP, IDE, MySQL, Curl API and apache installation

Is any installer which can configure PHP, IDE, MySQL,Curl API and Apache. my goal is to use Curl API using PHP. I am lots of trouble with manual installing. ...

How can I combine these three queries?

I have three MySQL queries I need to combine into a single query using joins. I'm having a lot of trouble figuring out how to do it though. Here are the three queries. select sum(A.a) from A join B on A.BID = B.id where B.userID=userID select sum(C.c) from D left join (C) on (D.id=C.DID) where D.userID = userID select...

How to count sub category level using PHP & MySQL.

I want to be able to count which sub category my new category is so i can give it its proper url value for example sub category 3 url value will be saved as &sub3=category Here is an category example. Web Design //parent category 0 Programming //sub-cat 1 HTML //sub-cat 2 Basics //sub-cat 3 SEO Networking The ...

Difference between performance of the two sql queries?

I have a field in my table having text data type. Is there a difference in performance for the following two sql queries: select * from tablename where fieldname="xyz%"; select * from tablename where fieldname="%zyx"; If we were to implement the execution of these queries, this is what I think we would need to do: We have to match...

SQL GROUP BY and NULL values: How can I group my results by only non-null values?

My query: SELECT *, contacts.createdAt AS contactcreatedAt, contacts.updatedAt AS contactupdatedAt, bidresponses.itemid AS bidresponseitemid, bidresponses.personid AS bidresponsepersonid, SUM(tagsitems.quantity) AS totalquantity FROM items LEFT OUTER JOIN tagsitems ON items.id = tagsitems.itemid LEFT OUTER JOIN items...

Free OLAP solution for .NET running on Mono / MySQL

I'm developing my university graduation project and I'd like to include an OLAP-based reporting module. In the past, I've used Mondrian with JPivot as an OLAP solution for Java projects and I'm looking for something similar using .NET. The tricky part is that my project should run on Mono and MySQL (installation environment is a Linux ...

SQL LEFT JOIN with COUNT(*) problem

I have the following query: SELECT products_categories.categoryID, name, COUNT(*) AS itemCount FROM products_categories LEFT JOIN products_to_categories ON products_to_categories.categoryID = products_categories.categoryID GROUP BY products_categories.categoryID But still there's a problem: categories with no products in them return i...

what more can I do to prevent myself from XSS injection & SQL Injection?

Hey! If my site ever goes live (don't think it will, its just a learning exercise at the moment). I've been using mysql_real_escape_string(); on data from POST, SERVER and GET. Also, I've been using intval(); on strings that must only be numbers. I think this covers me from sql injection? Correct? Can i do more? But, I'm not sure ho...

How to find prev and next id record from table

How to know prev id value and next id value from a table where id is given ? like ia have id=5 for a recod in table then i want to know the prev id value and next id value ...

mysql table name length limit? - please test on default mysql

Does vanilla MySQL have a table name length limit? (I've tested to 100 chrs on my modified MySQL - no limit so far.. I don't have vanilla MySQL accessible readily, though, but I wonder if my dynamically-created table schema will run on default MySQL) Question: What happens if you go over 64 chrs on default MySQL? Can you test this ple...

Mysql: Count records (including zero) per month

Hi, I am trying to count the records in my table and group them per date. My current query looks something like the following: SELECT count(*), MONTH(time) as month, YEAR(time) as year FROM myTable GROUP BY month, year ORDER BY year, month This works, except that I would also like to get a count for months where n...

How to retrieve a column after doing an UPDATE command in php and mysql

I'm new to php and sql. I have a table with three columns. One 256 bit hash number and two ints. I want to search for the row that matches my hash and then retrieve one int and increment the other. So, I thought I'd kill two birds with one stone by using first the UPDATE command. $query = sprintf("UPDATE %s SET activationcount = (activ...

How do I get XAMPP's MySQL and Ruby on Rails work together on my Mac?

I have mysql and apache running through XAMPP on my Mac machine (10.6.4). I usually do PHP development with this setup butnow I want to start out with Ruby on Rails. Unfortunately I cannot get mysql to work with RoR. I start the mysql Server with XAMPP and when I do "rake db:migrate" I get this output:!!! The bundled mysql.rb driver has ...

Unable to connect MYSQL database using JSP and TOMCAT

I am unable to connect database “test” created in mySQL using Java Server Pages (JSP) & Tomcat. I am getting the error message "Unable to connect to database". I am using following software specifications Tomcat 6.0 jdk1.6.0_21 mySQL 5.1.49 mysql-connector-java-5.1.13-bin I have configured following environment variables as follow ...

Getting last and next db-record by date in MySQL-Table?

Hey guys, I've got a certain question related to a blog, which I am developing in OOP (PHP) right now. All blogposts are stored in a MySQL-table. In the app you can read a specific post by giving the id of the post via GET-parameter. So like http://example.com/?id=2. Under the blogpost I want to show to navigation links like "previous"...

Running SQL from file MySQL - User Input?

Hi All, I'm running MySQL from the command line and executing SQL stored in files. What I'm trying to do, is prompt the user to enter input so that I can include this in the SQL script? Is there a way to do this with MySQL? Many thanks, James ...