Substr Mid Trim etc in sql 7 queries?? - Urgent!
#1
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
I want to do
select *
from [blah], [blah1]
where blah.x = Mid(Blah1,3)
so it would match all of fieldx to fieldy , but ignoring the first three chars in fieldy..
Make sense??
David
select *
from [blah], [blah1]
where blah.x = Mid(Blah1,3)
so it would match all of fieldx to fieldy , but ignoring the first three chars in fieldy..
Make sense??
David
#3
You can do it using an inner join which is most efficient as it'll use SQL's join strategy for query execution which should optimise more...
SELECT Table1.*, table2.* from table1 INNER JOIN table2 on mid([table1].[a],4) = mid([table2].[a],4)
Or just plain ol' select:
SELECT Table1.id, Table2.id
FROM Table1, Table2
WHERE (((Mid([table2].[a],4))=Mid([table1].[a],4)));
SELECT Table1.*, table2.* from table1 INNER JOIN table2 on mid([table1].[a],4) = mid([table2].[a],4)
Or just plain ol' select:
SELECT Table1.id, Table2.id
FROM Table1, Table2
WHERE (((Mid([table2].[a],4))=Mid([table1].[a],4)));
#4
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
MID is not a recognised database function or summit similar...
Ill give you a ring tomorrow.
David
Ill give you a ring tomorrow.
David
Trending Topics
#8
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
So should this not work??
as it doesnt...
CREATE VIEW dbo.Test
AS
SELECT Computer_System_DATA.MachineID,
Computer_System_DATA.InstanceKey,
Computer_System_DATA.RevisionID,
Computer_System_DATA.AgentID,
Computer_System_DATA.TimeKey,
Computer_System_DATA.CurrentTimeZone0,
Computer_System_DATA.Description0,
Computer_System_DATA.Domain0,
Computer_System_DATA.Model0,
Computer_System_DATA.Name0,
Computer_System_DATA.Roles0,
Computer_System_DATA.Status0,
Computer_System_DATA.UserName0,
Computer_System_DATA.Manufacturer00,
Computer_System_DATA.SystemType00, PCDetails.TagNo,
PCDetails.Department, PCDetails.Floor, PCDetails.House,
PCDetails.Opsys, PCDetails.Make, PCDetails.Processor,
PCDetails.HDSize, PCDetails.Memory, PCDetails.EquipType,
PCDetails.Model, PCDetails.SerialNumber,
PCDetails.TCPIPAddress, PCDetails.NetworkCard,
PCDetails.Comments, PCDetails.PurchaceDate,
PCDetails.DockingStation, PCDetails.LaptopUser,
PCDetails.LaptopManager
FROM Computer_System_DATA INNER JOIN
PCDetails ON
Computer_System_DATA.Name0 = SubString(PCDetails.TagNo,3,Len(PCdetails.TagNo))
Syntax runs ok but no data returned.
Its too early...
David
as it doesnt...
CREATE VIEW dbo.Test
AS
SELECT Computer_System_DATA.MachineID,
Computer_System_DATA.InstanceKey,
Computer_System_DATA.RevisionID,
Computer_System_DATA.AgentID,
Computer_System_DATA.TimeKey,
Computer_System_DATA.CurrentTimeZone0,
Computer_System_DATA.Description0,
Computer_System_DATA.Domain0,
Computer_System_DATA.Model0,
Computer_System_DATA.Name0,
Computer_System_DATA.Roles0,
Computer_System_DATA.Status0,
Computer_System_DATA.UserName0,
Computer_System_DATA.Manufacturer00,
Computer_System_DATA.SystemType00, PCDetails.TagNo,
PCDetails.Department, PCDetails.Floor, PCDetails.House,
PCDetails.Opsys, PCDetails.Make, PCDetails.Processor,
PCDetails.HDSize, PCDetails.Memory, PCDetails.EquipType,
PCDetails.Model, PCDetails.SerialNumber,
PCDetails.TCPIPAddress, PCDetails.NetworkCard,
PCDetails.Comments, PCDetails.PurchaceDate,
PCDetails.DockingStation, PCDetails.LaptopUser,
PCDetails.LaptopManager
FROM Computer_System_DATA INNER JOIN
PCDetails ON
Computer_System_DATA.Name0 = SubString(PCDetails.TagNo,3,Len(PCdetails.TagNo))
Syntax runs ok but no data returned.
Its too early...
David
#10
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
finally this works...
CREATE VIEW dbo.Test
AS
SELECT Computer_System_DATA.MachineID,
Computer_System_DATA.InstanceKey,
Computer_System_DATA.RevisionID,
Computer_System_DATA.AgentID,
Computer_System_DATA.TimeKey,
Computer_System_DATA.CurrentTimeZone0,
Computer_System_DATA.Description0,
Computer_System_DATA.Domain0,
Computer_System_DATA.Model0,
Computer_System_DATA.Name0,
Computer_System_DATA.Roles0,
Computer_System_DATA.Status0,
Computer_System_DATA.UserName0,
Computer_System_DATA.Manufacturer00,
Computer_System_DATA.SystemType00, PCDetails.TagNo,
PCDetails.Department, PCDetails.Floor, PCDetails.House,
PCDetails.Opsys, PCDetails.Make, PCDetails.Processor,
PCDetails.HDSize, PCDetails.Memory, PCDetails.EquipType,
PCDetails.Model, PCDetails.SerialNumber,
PCDetails.TCPIPAddress, PCDetails.NetworkCard,
PCDetails.Comments, PCDetails.PurchaceDate,
PCDetails.DockingStation, PCDetails.LaptopUser,
PCDetails.LaptopManager
FROM Computer_System_DATA INNER JOIN
PCDetails ON
substring(Computer_System_Data.Name0,4,(len(Comput er_System_Data.Name0)-3)) = pcdetails.tagno
just realised though that as one database holds the site location in different field and the other is the three chars that we are removing.... so told them to sort there db out.. by exporting ours... but proved that this can be done... or will when I tell them!
I owe you a pint nick.
David
CREATE VIEW dbo.Test
AS
SELECT Computer_System_DATA.MachineID,
Computer_System_DATA.InstanceKey,
Computer_System_DATA.RevisionID,
Computer_System_DATA.AgentID,
Computer_System_DATA.TimeKey,
Computer_System_DATA.CurrentTimeZone0,
Computer_System_DATA.Description0,
Computer_System_DATA.Domain0,
Computer_System_DATA.Model0,
Computer_System_DATA.Name0,
Computer_System_DATA.Roles0,
Computer_System_DATA.Status0,
Computer_System_DATA.UserName0,
Computer_System_DATA.Manufacturer00,
Computer_System_DATA.SystemType00, PCDetails.TagNo,
PCDetails.Department, PCDetails.Floor, PCDetails.House,
PCDetails.Opsys, PCDetails.Make, PCDetails.Processor,
PCDetails.HDSize, PCDetails.Memory, PCDetails.EquipType,
PCDetails.Model, PCDetails.SerialNumber,
PCDetails.TCPIPAddress, PCDetails.NetworkCard,
PCDetails.Comments, PCDetails.PurchaceDate,
PCDetails.DockingStation, PCDetails.LaptopUser,
PCDetails.LaptopManager
FROM Computer_System_DATA INNER JOIN
PCDetails ON
substring(Computer_System_Data.Name0,4,(len(Comput er_System_Data.Name0)-3)) = pcdetails.tagno
just realised though that as one database holds the site location in different field and the other is the three chars that we are removing.... so told them to sort there db out.. by exporting ours... but proved that this can be done... or will when I tell them!
I owe you a pint nick.
David
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM