Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 153 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

How do you write a backtick character inside of an inline code block?

Given the following SQL which requires backtick characters:

$sql="SELECT * FROM `my-table` LIMIT 1";

When I try to write it in inline form via backtick characters it gets corrupted like so:

$sql="SELECT * FROMmy-tableLIMIT 1";

I have tried using <code>...</code> but as soon as it sees two backtick characters, the code gets corrupted because the backticks disappear like so:

$sql="SELECT * FROM my-table LIMIT 1";

I've also tried using a combination of <code> and backticks such as:

<code>$sql="SELECT * FROM  </code><code>`</code><code>my-table</code><code>`</code><code> LIMIT 1";</code>

But it doesn't work because the two backticks have priority over the <code> and corrupt it like so:

$sql="SELECT * FROM </code><code>my-table</code><code> LIMIT 1";

The only workaround I've found is to use the &#96; entity but it doesn't work inside of backticks so I'm stuck using:

`$sql="SELECT * FROM `&#96;`my-table`&#96;` LIMIT 1";`

Which results in the ugly: $sql="SELECT * FROM`my-table`LIMIT 1";

What do you guys on here usually do when you need a backtick inside of an inline code snippet?

share|improve this question

migrated from stackoverflow.com Mar 15 '13 at 7:19

This question came from our site for professional and enthusiast programmers.

up vote 13 down vote accepted

As shown in Markdown help page, under Code Spans section:

If your code itself contains backticks, you may have to use multiple backticks as delimiters:

The name ``Tuple`2`` is a valid .NET type name.

Out put of this is: The name Tuple`2 is a valid .NET type name.

So in your case you use `` at the start and end of your statement. So it will look like:

$sql="SELECT * FROM `my-table` LIMIT 1";

share|improve this answer
    
Thanks! That's so much easier! – Ultimater Mar 15 '13 at 6:51

I figured it out:

<code>$sql="SELECT * FROM &#96;my-table&#96; LIMIT 1";</code>

Results in: $sql="SELECT * FROM `my-table` LIMIT 1";

share|improve this answer
    
This is ugly but works in cases the other answers don't work in. – caffinatedmonkey Jul 31 '15 at 21:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .