Hi there ! I got a spicy question about mysql...
The idea here is to select the n last records from a table, filtering by a property, (possibly from another table). That simple.
At this point you wanna reply :
let n = 10
SELECT *
FROM huge_table
JOIN another_table
ON another_table.id = huge_table.another_table_id
AN...
select xx as fieldA from ... group by xxx having fieldA is not null
I found that having has no effect
...
What's wrong with this code?
FROM product_tag, ps_product_tags_all
LEFT JOIN users ON
users.id = product_tag.lang
LEFT JOIN images ON
images.id = ps_product_tags_all.lang
Error:
Unknown column 'product_tag.lang' in 'on clause'
...
I want to display total number of products sold for each product. There are around 30 products in my virtue mart and I want each one's total sold number.
Table named jos_vm_order_item contains product_id and product_quantity with all other information.
How can I display this?
Please Help me out its very urgent for me.....
Thanks in a...
Hi guys, I am trying to dynamically create two drop down lists, one will be provinces, and the other will contain the cities of each province, so when a user chooses a province, the cities drop down will populate, I am using jQuery's $.ajax funtion to get the data from a database which then passes it back as JSON, here is what I have thu...
Hello all,
I'm looking for guidance. Here is what I'm doing.
I'm creating an advertising/publishing script using PHP and MySQL. At this time, the current program contains 41 million rows (7.5GB).
I'm thinking about storing real-time statistics and other data (users, ads, places, daily/monthly stats) on two mysql databases. And then up...
Hi,
I'm currently having a already a bash script with a few thousand lines which sends various queries MySQL to generate applicable output for munin.
Up until now the results were simply numbers which weren't a problem, but now I'm facing a challenge to work with a more complex query in the form of:
$ echo "SELECT id, name FROM type O...
Okey, so this is my problem.
I have a page structure saved into a mysql db.
Like this:
Page 1
- SubPage 1.1
- - SubPage 1.1.1
- - - SubPage 1.1.1.1
- - - SubPage 1.1.1.2
- - SubPage 1.1.2
- SubPage 1.2
- SubPage 1.3
Page 2
Page 3
The structure can have endless pages and sub pages. All pages have a field called "url" and "childof". "ch...
Simple question, could I conceivably use redis instead of mysql for all sorts of web applications: social networks, geo-location services etc?
...
Hi
I tried ..
SELECT c.* , (
SELECT COUNT( * )
FROM item t
WHERE t.cat_id = c.cat_id
)ct_items, (
SELECT COUNT( * )
FROM item t
INNER JOIN cat c3 ON t.cat_id = c3.cat_id
AND c3.cat_id = c.parent_id
) ct_sub
FROM cat c
WHERE parent_id = '0'
ORDER BY name
but got Unknown column 'c.parent_id' in 'on...
I was wondering what the simplest way of letting a table set ids automatically is, apart from AUTO_INCREMENT.
I have a table that will accumulate thousands of rows over a long period of time. Some of these rows will be deleted at a later time. How do I get new rows to get the lowest available id, without getting into doing it manually.
...
Hi guys,
I am trying to create JSON from a comma delimited string, the string look something like this:
One,Two,Three,Four,Five,Six,Seven
I need it to look something like this:
[{"test":"One"},{"test":"Two"},{"test":"Three"},{"test":"Four"},{"test":"Five"},{"test":"Six"},{"test":"Seven"}]
Here is the code I have thus far:
$stri...
Hi All,
On an older server I'm using that I can't use prepared statements on I am currently trying to fully escape user input before sending it to MySQL.
For this I am using the PHP function mysql_real_escape_string.
Since this function does not escape the MySQL wildcards % and _ I am using addcslashes to escape these as well.
When I s...
Okay, so for whatever reason I have ended up with a situation where the key is pointing the wrong way in a one-to-many. It was obviously never used as a one-to-many, only as a one-to-one, and now there is a need to expand one of those to be many, and the way the key was stored this turned out to be backwards.
The images table has a t...
I am developing a system which selects questions from a database to generate a test/exam.
Each question has a set 'question type' ('q_type'). I have a database of questions and need to select 4 questions, each with a different 'q_type'.
The basic query to select 4 random questions at the moment is:
SELECT * FROM questions ORDER BY RAN...
Hi guys, quick symfony / propel question.
I have the following propel collection route:
api_offer:
class: sfPropelRouteCollection
options:
prefix_path: /api/offer
model: Offer
plural: offers
singluar: offer
actions: [ list ]
module: apiOffer
requirements:
sf_format: (?:html|json)
My question is, does ...
Hi guys, I am trying to send a variable with jQuery's getJSON function but it doesn't seem to be going through, I am also unsure of how to get the variable I have just sent in the waiting PHP file, do I just reference it via the name I sent it as, for instance if I send a variable called 'test', can I get it like this, $_POST['test'] on ...
I have discovered that MySQL is returning odd results when searching on INT columns.
a)
SELECT *
FROM `sellers`
WHERE `seller_key` = '1'
Returns seller with the key 1.
b)
SELECT *
FROM `sellers`
WHERE `seller_key` = '1sdjhksadhak'
Returns seller with the key 1.
c)
SELECT *
FROM `sellers`
WHERE `seller_key` = '1a...
I have a table in the following format:
+---+---+--------+
| u | i | value |
+---+---+--------+
| 0 | 1 | Value1 |
| 0 | 2 | Value2 |
| 0 | 3 | Value3 |
| 8 | 2 | Value4 |
| 9 | 2 | Value5 |
| 9 | 3 | Value6 |
+---+---+--------+
My goal is to do a select that selects values from that user (u) for each id (i) if it exists, if not f...
Greetings, I've got a query that I'm struggling with, this is the first time that I am encountering this type of query.
I have two table as shown below.
xid is the primary key in parent_tbl1, while xid is the foreign key in child_tbl2
parent_tbl1
xid pub
1 1
2 1
3 0
4 1
child_tbl2
id ttype fno xid qnty
1 ...