Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2006, 11:14 AM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default data type mismatch

Hi

Can someone please help,I am having trouble creating a query.

I had a problem with two tables, one of them is linked from another database and only contains the first half of our unique number (before the full stop)

The other table contains a unique number in the format 06PG32.150203

With help, the following Expressions were used in a query in the table containing our unique number "Study_Number"

Expr1: InStr(1,[Variables]![Study_Number],".",0)
Expr2: Left([Variables]![Study_Number],[Expr1]-1)

Expr2 now shows only the first half of the Study_Number, but when I use it to try to make a join it keeps coming back with the data type mismatch message. I've gone through all the data and am convinced that it has something to do with the Expr2 field.

Does anyone have any suggestions how to fix this.

Thanks



 
Old April 5th, 2006, 11:46 PM
Authorized User
 
Join Date: Mar 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think INSTR() of mysql takes only 2 arguments...

INSTR(str,substr)
    Returns the position of the first occurrence of substring substr in string str.
example:-

SELECT INSTR('foobarbar', 'bar'); --will return
-> 4

check your expr1. I am sure about 'where clause' using 'instr function', they worked properly (for me).

Regards
Milind

 
Old April 5th, 2006, 11:55 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

mmmmm im confused. This is the SQL area, one would think you are refering to an SQL function, are you?. I am not aware of an SQL inStr function, however:

InStr is a VBScript function (yes it does take 4 argument however two of them are optional:

InStr([start, ]string1, string2[, compare])

Additionaly, I believe Left is a function in both languages:

LEFT (character_expression , integer_expression)
Returns the left part of a character string with the specified number of characters.

BTW if you want the SQL equivalent of inStr you may want to use:

SUBSTRING:
Returns part of a character, binary, text, or image expression.

Syntax
SUBSTRING ( expression , start , length )




Wind is your friend
Matt
 
Old April 6th, 2006, 07:58 AM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for all your suggestions,

Finally managed to get it to work, the problem was the data in the StudyNumber field (some didnt include a full stop and some were blank). Not much fun wading through thousands of records, but at least it's working now :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data type mismatch sharon5469 ASP.NET 1.0 and 1.1 Basics 2 May 27th, 2007 10:01 AM
Getting Data Type mismatch for autonumber somissac General .NET 4 March 1st, 2006 12:02 AM
Data type mismatch problem dominic_huang Classic ASP Databases 3 November 15th, 2004 03:12 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.