Solved

Substring??? MID????

Posted on 2002-04-30
13
423 Views
Last Modified: 2008-03-17
I am trying to get this query to work and I am getting this error on this part...


ISNULL((SELECT SUM(dbo_pm30200.DOCAMNT) FROM dbo_PM30200
WHERE SUBSTRING(dbo_pm30200.DOCNUMBR,5,3) = "LDG" and dbo_upr00100.employid = dbo_pm30200.vendorid),0)

It says that it doesn't recognize SUBSTRING().

SUBSTRING
---------
APR-LDG
MAY LDG
OCT/LDG
LDG ACD
FEB LDG 02

(5) Records.


What else could I use instead?
0
Comment
Question by:vbjohn
  • 7
  • 6
13 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6981820
mid


mid(string, startposition, length)

cheers
Ricky
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981826
or,

... where dbo_pm30200.DOCNUMBR like '*LDG*'...
0
 

Author Comment

by:vbjohn
ID: 6981847
Both of those do not work.  Thanks anyways.
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981882
ok,

the name of your table is 'dbo_pm30200', and the name of the field is 'DOCNUMBR', correct?


does this query work?

SELECT dbo_pm30200.DOCNUMBR
FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*"));
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981884
ldb, should be ldg ofourse...
0
 

Author Comment

by:vbjohn
ID: 6981896
Yes that query works.
0
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

 
LVL 12

Expert Comment

by:Paurths
ID: 6981916
what is the exact sql-string u are using now?
and what is your goal?
0
 

Author Comment

by:vbjohn
ID: 6981927
Yes that query works.
0
 
LVL 12

Accepted Solution

by:
Paurths earned 50 total points
ID: 6981931
SELECT Sum(dbo_pm30200.DOCAMNT) FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*") AND (([dbo_upr00100].[emplyid])=[dbo_pm30200].[vendorid]));
0
 

Author Comment

by:vbjohn
ID: 6983495
It seems like you can not have a query inside of a query.

For example:

SELECT RTRIM(LASTNAME) + ', ' + RTRIM(FRSTNAME)
    + ' ' + RTRIM(MIDLNAME) AS NAME, INACTIVE, ISNULL
        ((SELECT (dbo_UPR00400.MTDWAGES_1 + dbo_UPR00400.MTDWAGES_2+ dbo_UPR00400.MTDWAGES_3 + dbo_UPR00400.MTDWAGES_4+ dbo_UPR00400.MTDWAGES_5 + dbo_UPR00400.MTDWAGES_6+ dbo_UPR00400.MTDWAGES_7 + dbo_UPR00400.MTDWAGES_8+ dbo_UPR00400.MTDWAGES_9 + dbo_UPR00400.MTDWAGES_10+ dbo_UPR00400.MTDWAGES_11 + dbo_UPR00400.MTDWAGES_12) AS Wages
FROM dbo_UPR00400
WHERE dbo_UPR00100.EMPLOYID = dbo_UPR00400.EMPLOYID AND
dbo_UPR00400.PAYTYPE = 5 AND
dbo_UPR00400.PAYRCORD = '1SPSES'), 0) As PDTotal
FROM dbo_UPR00100 INNER JOIN dbo_UPR00400 ON dbo_UPR00400.EMPLOYID = dbo_UPR00100.EMPLOYID
ORDER BY dbo_UPR00100.EMPLOYID;


Is there a way to do it in Access?



John-
0
 

Author Comment

by:vbjohn
ID: 6983815
Using another Question....
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6983934
sure u can use another 'Select...' statement in another

u should have made clear u wanted a 0, or a number with that ISNULL statement...
0
 

Author Comment

by:vbjohn
ID: 6986494
Thanks for the help on the Wildcard thing!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 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

21 Experts available now in Live!

Get 1:1 Help Now