vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need Some Help With a Query. (https://vborg.vbsupport.ru/showthread.php?t=222337)

noonespecial 09-02-2009 10:21 PM

Need Some Help With a Query.
 
I have a mysql table with a bunch of band name - album names (for release dates):

Example: Paramore - Brand New Eyes

Now on a page I am grabbing all the results that match that particular band.

At the moment I am doing it like this:

title LIKE '%".$name."%'

However, this is searching through the entire word ... so if a band's name is in the album name for another artist ... it shows up incorrectly.

Is there anyway to fix this?

Dismounted 09-03-2009 06:03 AM

Ideally, you should have an Artist field, and an Album field. This allows much more flexibility, such as the case you are seeing now.

To take it even further, there should be separate "artist" and "album" tables, as there can one artist to many albums (one-to-many relationship). In fact, you could potentially need a many-to-many relationship (more than one artist to an album). Doing this is called database normalisation.


All times are GMT. The time now is 07:56 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01044 seconds
  • Memory Usage 1,706KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete