I've got 3 tables:
users (id, name, ...)
items (id, name, ...)
downloads (user_id, item_id, ...)
How do I get all users together with the number of downloads they have?
...
I am looking for the best solution for a LALR parser generator for C++ that will allow me to generate really good error messages. I really hate the syntax errors that MySQL generates and I want to take the parser in it and replace it with a "lint" checker that will tell me more than just
ERROR 1064 (42000): You have an error in your S...
$query = "SELECT UniqueID FROM configuration";
$result = mysql_query($query)or die(mysql_error());;
while($row = mysql_fetch_assoc($result)) { }
throwing exception as
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\ehp\hello.php on line 10
...
I have three tables (user, friends, posts) and two users (user1 and user2).
When user1 adds user2 as friend then user1 can see the posts of user2 just like on Facebook. But only the posts after the date when user1 added user2 as friend. My query is like this:
$sql = mysql_query("SELECT * FROM posts p JOIN friends f ON
p.curren...
I need advices for a table structure.
I need to create menus dynamically.
There will be more than 3 menus.
Some of menus will have multi-level structures.
What is the best way to strucure the menu tables?
All the menus are in one table
Each table should have one table
Any other??
Please give me your experience or common practices...
Hi,
I hope I can explain this good enough. I have 3 tables. wo_parts, workorders and part2vendor. I am trying to get the cost price of all parts sold in a month. I have this script.
$scoreCostQuery = "SELECT SUM(part2vendor.cost*wo_parts.qty) as total_score
FROM part2vendor
INNER JOIN wo_...
Is there a way to perform a FULLTEXT search which returns literals found within words?
I have been using MATCH(col) AGAINST('+literal*' IN BOOLEAN MODE) but it fails if the text is like:
blah,blah,literal,blah
blahliteralblah
blah,blah,literal
Please Note that there is no space after commas.
I want all three cases above to be retur...
How to connect with a database over the LAN?
I have only the name of the computer.
...
Is there a way to create a set from a string of separated values in MySQL? For example:
'the,quick,brown,fox'
=>
'the','quick','brown','fox'
A sort of inverse EXPORT_SET without the bit fiddeling.
Regards
...
The ComName is 'a'b'c'"def"j Limited.
i try to add \ before every ' and " but the resultant query that is executed is
"UPDATE empTable SET empId= '25', ComName = 'a'b'c'"def"j Limited where ID=1"
i don't see my Comname within '' and \ is not present before every ' and "
Here is the code to construct the column value
columnValue....
i have 2 tables linked together through the 3rd table
threads: id, name
tags: id, name
thread_tag_map: threads_id, tags_id
its a many to many relationship. i want to select 30 tags that are most popular that is to say the first 30 tags with tags_id which occur the most in thread_tag_map.
i think you understand my question (and sorry ...
I want to pull out menu items from MySQL.
Main menu id=1, parentid=0
-Contact us id=2, parentid=1
-Music id=3, parentid=1
--Rock id=8, parentid=3
--Classic id=9, parentid=3
-Car id=4, parentid=1
--Toyota id=5, parentid=4,
--Ford id=6, parentid=4...
I'm trying to retrieve books from one table and left join the chapters table. What I need from the second table is just the COUNT() of chapters available for those books and add that value as an extra column called chapters (or something else).
My current try looks like this:
SELECT b.*, count(c.chapter_nr) as chapters FROM books as b l...
I have this sql
select concat( char(FLOOR(97+ RAND()*26))
, char(FLOOR(97+ RAND()*26))
, FLOOR(100+ RAND()*999)
, char(FLOOR(97+ RAND()*26))) AS randomcode
WHERE NOT EXISTS (
SELECT *
FROM table
WHERE code_felt = randomcode );
But I can't get it to work. D...
Here is the select statement I'm using. The problem happens with the sorting. When it is like below, it only sorts by t2.userdb_user_first_name, doesn't matter if I put that first or second. When I remove that, it sorts just fine by the displayorder field value pair. So I know that part is working, but somehow the combination of the two ...
I keep getting these errors when trying to delete rows from a table. The special case here is that i may be running 5 processes at the same time.
The table itself is an Innodb table with ~4.5 million rows. I do not have an index on the column used in my WHERE clause. Other indices are working as supposed to.
It's being done within a tr...
TableA
id, name
1, abc
2, cde
3, def
TableB
id, TableA_id, topic
1, 1, blah
2, 1, blah again
3, 2, abcdef
I want to select all of those records from TableA which dont have any references in TableB. How do I do it in Mysql?
Thanks a lot.
...
Imagine hexagonal space with 3 dimensions.
Each tile has coordinates XYZ.
I need to select a given cell neighbors in the same plane.
With SQL it's looks like:
$tbDir = $y % 2 == 0 ? -1 : 1;
$result = db_query('SELECT x,y,z FROM {cells} WHERE
x = %d AND y = %d AND z = %d OR
x = %d AND y = %d AND z = %d OR
...
How to bind SQL variables in Php?
I want to bind variables instead of just building SQL strings.
Anyway to do this in Php?
either MySQL or PostgreSQL answers would help.
Thanks
...
I have an update statement that updates fields x, y and z where id = xx.
In the table I have a few different x_created_datetime fields (for different portions of the record that are maintained/entered by different folks). I'd like to write a single query that will update this field if is null, but leave it alone if is not null.
So what...