mysql

How separate search results by category? MySQL + PHP

Hi! I didn't get any code that worked. Of course I could have use then wrongly because I'm a beginner. Some told me to use MySQL subqueries other told me to use PHP foreach achieve it. What I want is to show the search results of a keyword separated by groups of categories, something like that: Search results for Item, 3 itens in 2 ca...

SQL Selection of products in a single category

So here is what I am trying to do. My boss wants to put all vehicles that we have on our homepage and randomly pull 8 of them at a time. The way our database schema is setup has the products, and categories in separate tables using a cross reference to locate the category the product falls under. The table with the categories has a paren...

Why does this MySQL query give "error 1136" when inserting values into table

Query: INSERT INTO Customer2 VALUES (1, 'Mrs','Jill','Hill','2 Step St','Hillington','Uxbridge', 'Middx''UB10 8XY','020 8999 684') ; ...

Django / MySql not honouring unique_together

I am using django with mysql (InnoDB) and have the following in my django model: class RowLock(models.Model): table_name = models.CharField(blank = False, max_length = 30) locked_row_id = models.IntegerField(null = False) process_id = models.IntegerField(null = True) thread_id = models.IntegerField(null = True) class...

MySQL Join Multiple Table

News nID nTitle ----------- 1 test Keyword kID kWord nID -------------- 1 abc 1 2 def 1 3 ghj 1 So i fetch it like $sql = mysql_query("SELECT * FROM news as n, keyword as k WHERE n.nID = k.nID"); PHP while($row = mysql_fetch_array($sql))...

query datetime string with time value

i have a datetime string in my DB like "2010-08-15 00:00:00" how do i query only the time part. suppose i want to retrieve all rows that have the time "00:20:00"? ...

Validation of existence per result on a indexed list, mysql/php

We have a directory system that lists people with their credentials such as email phone and etc Their web profile link is also listed. but this link is created by taking the email username and adding it to a link. so [email protected] has a profile page at school.com/user/joe01 currently there is no validation to check if the actual user...

How to export MS SQL database to MYSQL?

I'm trying to convert from a MSSQL .bak database to MYSQL. This question and answers have been very useful, and I have successfully imported the database, but am now stuck on exporting to MYSQL. The MYSQL Migration Toolkit was suggested, but seems to have been replaced my the MYSQL Workbench. Is it possible to use the MYSQL Workbench to...

Converting MySQL TEXT field with breaklines to XML by Perl script returns a malformed notation

I have a table in MySQL that has one field defined as TEXT. The information is fed to the database by a webform using a textarea. I'm using the following script to generate an XML with the information of the table: #!/usr/bin/perl use strict; use DBI; use XML::Generator::DBI; use XML::Handler::YAWriter; my $dbh = DBI->connect ("DBI:...

MySQL date range SELECT + JOIN query using column with CURRENT_TIMESTAMP

I am using this query: SELECT p.id, count(clicks.ip) FROM `p` LEFT JOIN c clicks ON p.id = clicks.pid WHERE clicks.ip = '111.222.333.444' To select clicks from table "c", that has "pid" = "p.id". The query seems to work fine, but now I want to use that query with date ranges. The "c" table has a column "time" that uses MySQL CURRENT_T...

PHP & MySQL query question.

How can I check each value in each array in my MySQL query. I hope this makes sense. SELECT articles_comments.comment_id FROM articles_comments WHERE articles_comments.comment_id = Array ( [0] => 5 [1] => 6 [2] => 10 [3] => 11 [4] => 12 [5] => 17 [6] => 3 [7] => 4 [8] => 7 [9] => 8 [10] => 9 ...

SQL Distinct Query for Two Tables

Table1: id - name - address ----------------------------- 1 - Jim - Some Street 2 - Adam - Some Street 3 - ABC - Some Street Table2: id - job - finished_by --------------------------- 1 - ABC - 2 2 - EFD - 3 3 - XYZ - 2 4 - BVC - 1 In the above two tables Table1.id an...

SQL query execution - different outcomes on Windows and Linux

The following is generated query from Hibernate (except I replaced the list of fields with *): select * from resource resource0_, resourceOrganization resourceor1_ where resource0_.active=1 and resource0_.published=1 and ( resource0_.resourcePublic=1 or resourceor1_.resource_id=resource0_.id ...

How can I find the Unix process that owns a local Sleeping MySQL connection?

I'm fighting a 'Too many connections' problem with my MySQL process and I've got to the point when mysqladmin processlist -uroot -pXXXXX results in: +------+------------+-----------+------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------...

MySQL XA Transaction in two different connections, rollback of one doesnt rollback all

Hi all! maybe I totally misunderstand XA Transactions (I'm no DBA), but I have the following problem: - I open two sql connections (to the same DB) - "set autocommit=0" in both sessions - XA start '1234','56'; in one session - XA start '1234','57'; in other session - insert something in both sessions - "xa end", "xa prepare" and "xa com...

MySQL: How to select and display ALL rows from one table, and calculate the sum of a where clause on another table?

I'm trying to display all rows from one table and also SUM/AVG the results in one column, which is the result of a where clause. That probably doesn't make much sense, so let me explain. I need to display a report of all employees... SELECT Employees.Name, Employees.Extension FROM Employees; -------------- | Name | Ext | ------------...

Difference in SHA1 in .NET and MySQL

Hey, I have a couple different bits of code but the short story is I insert some passwords into a MySQL database using SHA1 and also compute SHA1 hashes into .NET and they are not matching. I think this is a problem with my encoding code in .NET. SQL Code: INSERT INTO user_credentials (Password) VALUES (SHA1('password')); password h...

Proper way to organize MySQL queries in code?

I need some ideas to make my code a bit cleaner for a pretty simple application with a simple database. I have the following idea but it's not working quite well. This is what I'm doing: I have many queries on a page (takes up a lot of space and souce code looks messy. I'd like to have an index of them in another PHP file that I could c...

Good database for large table with simple key access

I have a few large databases, greater than 100 million records. They consist of the following: A unique key. An integer value, not unique, but used for sorting the query. A VARCHAR(200). I have them in a mysql isam table now. My thought was, hey, I'll just set up a covering index on the data, and it should pull out reasonably fast....

NHibernate Inner Join Fetch Only Some Columns ?

Hello Guys, I'm developing an application with nHibernate and MySQL. I have a HQL command that runs every second, and in this command I do a "Inner Join Fetch", like this: "from Order o inner join fetch o.Customer order by o.Date" It's work fine but It fill all properties of "Customer", and I have a lot of columns in DataBase (al...