|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Substring and Variable Help
One more question, then I'm done honestly. I need a query that does four things.
First Name = Frank Last Name = Leppar User ID = 300503 I need a fourth field that grabs the f.i. of first name, f.i. of last name, makes them both lower case, and then combines it with the student id: eq: fl300503 Not hard right? I apologize on this one but I have no idea where to even get started on this. Again this is on a PHP site so I'm sure that will help. NimirRamon who has already helped me out so much on these forums, posted this formula: Code:
LOWER(SUBSTRING(0,1,[First Name]) + LOWER(SUBSTRING(0,1,[Last Name]) + [User ID] He also stated it may not be exactly right, but at least I understand where to go with it. The problem is Im using a PHP page and all I do is grab the data from the previous text fields and input them into the database - so where should I post this query and what else would I have to do in order to get everything working? |
|
#17
|
||||
|
||||
|
First of all, that's not a query. It's just an excerpt from a query. Also, it is wrong. It's odd, but unlike many other languages SQL Server SQL strings are 1-indexed. I'll leave it as an exercise to you to apply that nugget- it's the best way for you to learn.
I'm no PHP expert, so I can't help you use the sql in php unless you give me more to go on from that side.
__________________
Primary Forums: .Net Development, MS-SQL, C Programming VB.Net: It's not your father's Visual Basic. [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers] |
|
#18
|
|||
|
|||
|
Quote:
Yeah I just gave an SQL excerpt for the chunk he was having difficulty with, really is more use in a simple update thinking about it. Gah, I'd forgotten about it being 1-indexed (more fool me), I always default to 'traditional' indexing out of habit. fleppar, I think I misunderstood your initial requirements (or was in too much of a state to think properly), you could use PHPs string functions to do the lower casing, substringing and concatenation. Something like PHP Code:
Then you could use '$code' in the insert Again apologies for any/all mistakes in the above, the logic is sound in my head, but Im running off a rather dodgy memory here. |
|
#19
|
|||
|
|||
|
Quote:
I just spoke with someone and we worked it out and got one that works - lemme quote what we came up with. PHP Code:
hah exact same thing Ramon! I just based it off of the older equation you started me out with, so it's basically the same thing. I guess I could be worried about efficiency and make it: PHP Code:
Something about math and "Simplify this equation" involved there. Either way - thanks a lot for all the help everyone. This has to be the one of the best, if not the best community for new developers and advanced ones alike. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Update All Records in a Row - Query Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|