Solved

VB.NET -> sql select query

Posted on 2014-02-12
4
429 Views
Last Modified: 2014-02-28
Hello,

I would like to select * from mysql table where Hometeam ="" or Awayteam=""

Then thing is I pull a list of matches that will be played each day so for instance today matches are:

23:20 Fortaleza V Ferroviario Fortaleza
22:30 Sao Paulo RS V Brasil de Pelotas
22:30 Rio Branco SP V Guaratingueta
22:30 Velo Clube V Ferroviaria
22:30 Sao Caetano V Mirassol
22:30 Itapirense V Osasco
22:00 Barbarense V Capivariano
21:45 Deportivo Anzoategui V Penarol
21:30 Ponte Preta V Ituano
21:30 Chapecoense V Hermann Aichinger
21:30 America MG V URT
21:00 Sociedad V Barcelona
21:00 Gremio Barueri V Santo Andre
20:00 Fulham V Liverpool
19:55 Nice V Monaco
19:45 Arsenal V Man Utd
19:45 Newcastle V Tottenham
19:45 Man City V Sunderland
19:45 Everton V C Palace
19:45 Stoke V Swansea
19:45 Sheff Utd V Brentford
19:45 Napoli V Roma
19:30 Hamburg V B Munich
19:00 Ourense V CD Alcala
18:45 Groningen V Twente
18:00 Hoffenheim V Wolfsburg
18:00 Leverkusen V Kaiserslautern
18:00 GAIS V Falkenbergs
18:00 Eskisehirspor V Sivasspor
18:00 Galatasaray V Antalyaspor
18:00 Bursaspor V Akhisar Belediye
18:00 Atromitos V Olympiakos
18:00 Real Union V SD Balmaseda FC
18:00 SC Wiedenbruck V FC Koln II
18:00 Netherlands (W) V Belgium (W)
18:00 Monte Azul V Guarani SP
18:00 Sao Jose EC SP V Catanduvense
17:45 Auxerre V Rennes
17:30 Supersport Utd V MP Black Aces
17:30 Platinum Stars V Bloemfontein Celtic
17:00 Hapoel Haifa V Hapoel Kiryat Shmona
16:00 Zaragoza B V CD Guadalajara
15:00 Dinamo Moscow V Dnipro
15:00 Olympiakos Volou V Panathinaikos
14:30 Arka Gdynia V Stomil Olsztyn
13:30 Ural V Rostov


how could i loop through to get each team name and place them in the Hometeam= "" and awayteam ="" ????
0
Comment
Question by:runnerjp2005
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39853653
Not sure I understand the problem. You have a list of match strings as shown in question and you want to split these into home town and away town? How would you identify that? Is the first team always the home team?
0
 

Author Comment

by:runnerjp2005
ID: 39853691
correct first team is always home....

In essence i would like to do something like this

select * from mysql table where Hometeam ="Stoke" or Awayteam="Stoke" or Hometeam ="Swansea" or Awayteam="Swansea" or Hometeam ="Sheff%Utd" or Awayteam="Sheff%Utd" or Hometeam ="Brentford" or Awayteam="Brentford" .......

Notice the % inbetween Sheff%Utd as where a space is i would like to search if its like  Sheff%Utd incase its listed as Sheffield Utd
0
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 39854074
I wasn't sure where the matches were so I wrote the VB assuming the matches were in a list box.  I'm sure the split can be done with regex but this works too.

        Dim strWords As String()
        Dim strQuery As String

        For Each strMatch As String In ListBox2.Items
            strMatch = strMatch.Replace(" V ", " - ") 'Replace V with - to avoid issues with teams with a V in the name
            strWords = strMatch.Substring(5).Split(New Char() {"-"})


            strQuery = "Select * from mysql table where Hometeam = '" + strWords(0).Trim + "' Or Awayteam = '" + strWords(1).Trim + "'"
        Next

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39854247
"Stoke" hmm. That brings back some memories :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now