vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Search [alphabetically, first letter] a | b | c | d | e.. ? (https://vborg.vbsupport.ru/showthread.php?t=60545)

Harlequin 01-21-2004 03:18 PM

Search [alphabetically, first letter] a | b | c | d | e.. ?
 
I'm new to the SQL searching thing and I've been trying to figure out a way to allow a user search via the first letter on a certain table, such as "title" or "topic" or something.


So by a user clicking a or b or c or d.. so on and so forth..

The result would bring back and alphabetical order of topics with -just- that letter (such as the example below).

If user clicks A, result is:

alien
alligator
ant
art
asp

If user clicks B, result is:

beast
bite
brake
butter

..

I'm assuming to get the function to go alphabetical, it'd be GROUP BY or ORDER BY with an ASC or DESC, but the searching via a first letter is kind of killing me. ;)

NTLDR 01-21-2004 03:38 PM

[sql]WHERE like 'a%'[/sql]

That would get all entries where the title column starts with an 'a'.

Xenon 01-21-2004 03:55 PM

if you want to ignore cases it's

[sql]WHERE UCASE(fieldname) LIKE 'A%'[/sql]

NTLDR 01-21-2004 03:57 PM

It normally seems to ignore the case anyway, at least on 4.0.15, I just tried and got A and a returned. Although normally I'd put a case check in to be sure ;)

Harlequin 01-21-2004 04:34 PM

Wow. Thanks for the speedy replies. :)

I'll definitely give it a shot.

Thankies thankies!

Xenon 01-21-2004 04:38 PM

Quote:

Originally Posted by NTLDR
It normally seems to ignore the case anyway, at least on 4.0.15, I just tried and got A and a returned. Although normally I'd put a case check in to be sure ;)

hmm, it didn't ignore cases when i checked it lasttime, and i know other DB's like DB2 don't ignore it.

bah, maybe it's just a setting, which is changeable ;)


All times are GMT. The time now is 07:02 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.01088 seconds
  • Memory Usage 1,719KB
  • 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)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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