473,473 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting similar rows (same title, different description)

HaLo2FrEeEk
404 Contributor
I'm still working on my project with the challenges, and wanted to try something. Every day new daly challenges are put out. I track them and save them to a database. Sometimes the challenges are reused, in those cases I simply reference the saved challenge in the database, instead of putting in a new row. Other times, however, the challenge title is the same as one previously used, but the requirements or rewards are different. For example:

A Solid Outing - Earn at least 15 kills in a multiplayer Matchmaking game. (reward: 3000)
A Solid Outing - Earn at least 15 kills in a multiplayer Matchmaking game. (reward: 1500)
A Solid Outing - Earn at least 12 kills in a multiplayer Matchmaking game. (reward: 1300)

All three have the same title, the first two have the same requirements but a different reward, the last one has different requirements. I'd like to group these together, so that if today's challenge is the first one (reward 3000), I can show any information about the other two as well. Is there a simple, one-off query for this, or would I be better off simply running a query like this:

SELECT * FROM table WHERE title = "A Solid Outing"

And using PHP to go from there.
Mar 21 '11 #1
6 2166
Rabbit
12,516 Recognized Expert Moderator MVP
I'm not sure what you're looking for. Given an existing dataset, and given an input, what result are you looking for?
Mar 21 '11 #2
HaLo2FrEeEk
404 Contributor
I store the challenges so that people can post tips on the best way to complete them. The tips are stored in a separate table. A tip for a specific challenge will contain that challenge's ID in the row.

Let's say today's challenge is one of the ones I used in my example above, we'll go with the first one, which has an ID of 33. I'll want all tips for challenge ID 33, but since the other two (IDs 69 and 136) are similar to the first one, I'd also like to get any tips for those challenges as well, so I basically need to get the chalenge IDs from the challenge table for a specified title, then get any tips in the tips table for those IDs.

I think LEFT JOIN is gonna work for me here, I just have to figure out the query.
Mar 21 '11 #3
Rabbit
12,516 Recognized Expert Moderator MVP
In your case, then yes, you will need to pull the different IDs by the name of the challenge. However, since for any one challenge, the thresholds to complete them can vary, the data should be separated. I would probably store the thresholds in the daily challenges table if they vary day by day. That way, you only have one challenge ID instead of three for the same challenge.
Mar 21 '11 #4
HaLo2FrEeEk
404 Contributor
I was thinking, perhaps have a table with just the titles, then another table with the requirements. Rows in both tables would have an ID and could be linked together, so for example I'd have one row in the titles table called "A Solid Outing", then I'd have 3 rows in the description table for each of the requirements / rewards, each of them would have a field linking it to the title row. Let's say today's challenge is the one worth 3000, I'd use the title from the titles table. That might work.

I did get a working query with LEFT JOIN though, but it's at home and I don't remember it.
Mar 21 '11 #5
Rabbit
12,516 Recognized Expert Moderator MVP
If you're trying to join to the tips table, you don't really need an outer join. Since you only want tips whose ID match the ones you're pulling, an inner join should work.
Mar 21 '11 #6
HaLo2FrEeEk
404 Contributor
I don't remember if it's an outer join or just a regular left join, I think it goes something like this:

SELECT * FROM challenges C LEFT JOIN tips T ON C.id = T.challenge_id WHERE title = 'some title';

I could have it wrong though. I'm not using it currently, but I copied it into my PHP and commented it out, so i'd have it if I needed it. Basically the query gets. All of the tips for all of the challenges that have a specific title.
Mar 21 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Atanas Boev | last post by:
I have a heading that I would like to link to site section, in the following context: <h1>Site Contents</h1> <h2>First Section</h2> <h2>Second Section</h2> <h2>Third Section</h2> I want...
6
by: Pedro Alves | last post by:
Hi I'm having serious problems with a mission critical app that runs on postgres (and has been running for the past 3 years). It's rather large, and lately things are not going well. The...
5
by: sql-db2-dba | last post by:
We have DB2 UDB v8.1 fixpak3 on AIX 5. Production and Development configuarations (at least for DB2) are identical albeit production is a 2-way server while development has only one processor....
2
by: clintonG | last post by:
Does it seem to be a general consensus that CDATA within the title and the description is widely supported at this point in time is a means to allow users to submit data such as the word AT&T in an...
2
kaleeswaran
by: kaleeswaran | last post by:
hi! i want to know ..how to getting multiple rows from the database using ajax.and i pass these value to the javascript.give me solution... ...
3
by: fran7 | last post by:
Hi, When I put asp in my title and description, I get a type mismatch error. I dont get it when the page has the full database address like so http://www.mysite.com/page.asp?Author=aaaa%20aaaaaaa...
1
by: olddocks | last post by:
i am planning to code a script in php for bookmarking. how to pull title and description from a given URL? Is there special functions exist within PHP?
2
by: rathour | last post by:
<?php session_start(); require_once('db.php'); include('functions.php'); $user = get_username ( $_SESSION ); //if ( $_SESSION ): checkLogin ( '1 2' ); ?>
9
by: SuperNova | last post by:
Hello! I need to mark similar phrases in two different texts, for example to use <btag. Example: text 1: Google Chrome is a browser that combines a minimal design with sophisticated...
1
by: sree ram | last post by:
code for getting maximum rows in excel sheet using perl script
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.