string concatenation and apostrophe marks

mHelpMe

I have a long sql query that I am writing in MATLAB. To make it easier for people to read what is it doing I am trying to break the query on to a few lines rather than one long line.

Below is my code (names changed).

sql_statement = strcat('select some_feilds from'...
                       ,' databaseOne.tableOne'...
                       ,' join databaseTwo.tableTwo'...
                       ,' on databaseOne.tableOne.f1 = databaseTwo.tableTwo.f2'...
                       ,' where databaseTwo.tableTwo.f2 =','''', x_lbl(1, 1),'');

The issue I have is the x_lbl(1,1) needs an ' either side of it. i.e f2 = 'Health'.

The code above gives me ''Health' which is rather fustrating as when I just the do the line below I get 'Health'. Maybe I'm going blind and losing my mind but can't see to get my query in the correct format?

 lbl = strcat('''', x_lbl(1,1), '''');

update

 x_lbl(1,1)
 ans = 'Health Care'


 sql_statement = [1x225 char]

that's the answer when using the last line,

,' where DVLP_QES.dbo.num_name_mapping.name = ','''', x_lbl(1, 1),'''');
Berriel

마지막에 작은 따옴표를 2 개 더 추가해야하는 sql_statement것처럼 완료 해야하는 경우 :select [...] tableTwo.f2 ='Health'strcat

sql_statement = strcat('select some_feilds from'...
                       ,' databaseOne.tableOne'...
                       ,' join databaseTwo.tableTwo'...
                       ,' on databaseOne.tableOne.f1 = databaseTwo.tableTwo.f2'...
                       ,' where databaseTwo.tableTwo.f2 =','''', x_lbl(1, 1),'''');

나는 x_lbl(1, 1) = Health따옴표없이 생각 했죠 ?

편집하다:

MATLAB R2014a 사용

>> x_lbl = 'Health';
>> x_lbl
x_lbl =
Health
>> sql_statement = strcat('select some_feilds from'...
                       ,' databaseOne.tableOne'...
                       ,' join databaseTwo.tableTwo'...
                       ,' on databaseOne.tableOne.f1 = databaseTwo.tableTwo.f2'...
                       ,' where databaseTwo.tableTwo.f2 =','''', x_lbl,'''');
>> sql_statement
sql_statement =
select some_feilds from databaseOne.tableOne join databaseTwo.tableTwo on databaseOne.tableOne.f1 = databaseTwo.tableTwo.f2 where databaseTwo.tableTwo.f2 ='Health'

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

String initialisation and concatenation in java

분류에서Dev

Simplify CTE string concatenation?

분류에서Dev

String concatenation in Access VBA

분류에서Dev

Ruby on Rails String Concatenation

분류에서Dev

Powershell string concatenation of expressions

분류에서Dev

Matlab string concatenation for file creation

분류에서Dev

Newlines and their effect in String concatenation in Javascript

분류에서Dev

Confusing JavaScript statement about string Concatenation

분류에서Dev

What is wrong in this string concatenation using JavaScript?

분류에서Dev

How do you escape apostrophe in single quoted string in bash?

분류에서Dev

String.Join with String concatenation : 코드 개선

분류에서Dev

C# Regex to match a string that has double bars that are not in quotation marks

분류에서Dev

Using javascript: How can a variable be added to a string containing quotation marks?

분류에서Dev

How to execute PHP code after automaticly creating it using string concatenation?

분류에서Dev

sed command string variable concatenation within single quotes

분류에서Dev

Remove special character and apostrophe and unwanted space in string using re.sub function in python

분류에서Dev

How do i get c# to write quotation marks when declaring a string?

분류에서Dev

Escape apostrophe in Query of Query

분류에서Dev

add apostrophe to regex match

분류에서Dev

Using an apostrophe inside a query

분류에서Dev

Powershell String Concatenation은 문자열을 무작위로 배치합니다.

분류에서Dev

Javascript quotation marks and commas

분류에서Dev

Using Exclamation Marks '!' in C

분류에서Dev

Issues with MySQL and quotation marks

분류에서Dev

StringFormat Binding with Apostrophe in XAML Not Working

분류에서Dev

concatenation of arrays in system verilog

분류에서Dev

sybase - simple concatenation

분류에서Dev

argument concatenation in a recursive function

분류에서Dev

SQL WHERE clause with concatenation

Related 관련 기사

  1. 1

    String initialisation and concatenation in java

  2. 2

    Simplify CTE string concatenation?

  3. 3

    String concatenation in Access VBA

  4. 4

    Ruby on Rails String Concatenation

  5. 5

    Powershell string concatenation of expressions

  6. 6

    Matlab string concatenation for file creation

  7. 7

    Newlines and their effect in String concatenation in Javascript

  8. 8

    Confusing JavaScript statement about string Concatenation

  9. 9

    What is wrong in this string concatenation using JavaScript?

  10. 10

    How do you escape apostrophe in single quoted string in bash?

  11. 11

    String.Join with String concatenation : 코드 개선

  12. 12

    C# Regex to match a string that has double bars that are not in quotation marks

  13. 13

    Using javascript: How can a variable be added to a string containing quotation marks?

  14. 14

    How to execute PHP code after automaticly creating it using string concatenation?

  15. 15

    sed command string variable concatenation within single quotes

  16. 16

    Remove special character and apostrophe and unwanted space in string using re.sub function in python

  17. 17

    How do i get c# to write quotation marks when declaring a string?

  18. 18

    Escape apostrophe in Query of Query

  19. 19

    add apostrophe to regex match

  20. 20

    Using an apostrophe inside a query

  21. 21

    Powershell String Concatenation은 문자열을 무작위로 배치합니다.

  22. 22

    Javascript quotation marks and commas

  23. 23

    Using Exclamation Marks '!' in C

  24. 24

    Issues with MySQL and quotation marks

  25. 25

    StringFormat Binding with Apostrophe in XAML Not Working

  26. 26

    concatenation of arrays in system verilog

  27. 27

    sybase - simple concatenation

  28. 28

    argument concatenation in a recursive function

  29. 29

    SQL WHERE clause with concatenation

뜨겁다태그

보관